> Documentation index: https://firebase.google.com/docs/reference/js/llms.txt

## Functions

| Function | Description |
|---|---|
| **function()** |   |
| [countAll()](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#countall) | Creates an aggregation that counts the total number of stage inputs. |
| [currentDocument()](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#currentdocument) | Creates an expression that represents the current document being processed. |
| [currentTimestamp()](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#currenttimestamp) | Creates an expression that evaluates to the current server timestamp. |
| [rand()](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#rand) | Creates an expression that generates a random number between 0.0 and 1.0 but not including 1.0. |
| [rank()](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#rank) | ***(Public Preview)*** Returns the rank of each document within its partition according to the window's sort order. Documents with equal sort values receive the same rank, and the following rank is skipped. The window must specify exactly one sort ordering.Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes |
| [score()](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#score) | Evaluates to the search score that reflects the topicality of the document to all of the text predicates (for example: `documentMatches`) in the search query. If `SearchStageOptions.query` is not set or does not contain any text predicates, then this topicality score will always be `0`. |
| **function(array, ...)** |   |
| [arrayContains(array, element)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontains_a00ea48) | Creates an expression that checks if an array expression contains a specific element. |
| [arrayContains(array, element)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontains_7328608) | Creates an expression that checks if an array expression contains a specific element. |
| [arrayContainsAll(array, values)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontainsall_c658ad5) | Creates an expression that checks if an array expression contains all the specified elements. |
| [arrayContainsAll(array, arrayExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontainsall_7b535db) | Creates an expression that checks if an array expression contains all the specified elements. |
| [arrayContainsAny(array, values)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontainsany_c658ad5) | Creates an expression that checks if an array expression contains any of the specified elements. |
| [arrayContainsAny(array, values)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontainsany_c381a96) | Creates an expression that checks if an array expression contains any of the specified elements. |
| [arrayLength(array)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraylength_195e339) | Creates an expression that calculates the length of an array expression. |
| **function(arrayExpression, ...)** |   |
| [arrayFilter(arrayExpression, alias, filter)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayfilter_892d3c4) | Creates an expression that filters an array using a provided alias and predicate expression. |
| [arrayFirst(arrayExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayfirst_f574e12) | Creates an expression that returns the first element of an array. |
| [arrayFirstN(arrayExpression, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayfirstn_bff7f91) | Creates an expression that returns the first `n` elements of an array. |
| [arrayFirstN(arrayExpression, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayfirstn_19b4ef8) | Creates an expression that returns the first `n` elements of an array. |
| [arrayGet(arrayExpression, offset)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayget_f2e27cc) | 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. |
| [arrayGet(arrayExpression, offsetExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayget_484550d) | 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. |
| [arrayIndexOf(arrayExpression, search)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayindexof_694a0b4) | Creates an expression that returns the first index of the search value in an array. Returns -1 if the value is not found. |
| [arrayIndexOfAll(arrayExpression, search)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayindexofall_694a0b4) | Creates an expression that returns all indices of the search value in an array. |
| [arrayLast(arrayExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraylast_f574e12) | Creates an expression that returns the last element of an array. |
| [arrayLastIndexOf(arrayExpression, search)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraylastindexof_694a0b4) | Creates an expression that returns the last index of the search value in an array. Returns -1 if the value is not found. |
| [arrayLastN(arrayExpression, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraylastn_bff7f91) | Creates an expression that returns the last `n` elements of an array. |
| [arrayLastN(arrayExpression, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraylastn_19b4ef8) | Creates an expression that returns the last `n` elements of an array. |
| [arrayMaximum(arrayExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraymaximum_f574e12) | Creates an expression that returns the maximum value in an array. |
| [arrayMaximumN(arrayExpression, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraymaximumn_bff7f91) | Creates an expression that returns the largest `n` elements of an array.Note: Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined. |
| [arrayMaximumN(arrayExpression, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraymaximumn_19b4ef8) | Creates an expression that returns the largest `n` elements of an array.Note: Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined. |
| [arrayMinimum(arrayExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayminimum_f574e12) | Creates an expression that returns the minimum value in an array. |
| [arrayMinimumN(arrayExpression, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayminimumn_bff7f91) | Creates an expression that returns the smallest `n` elements of an array.Note: Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined. |
| [arrayMinimumN(arrayExpression, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayminimumn_19b4ef8) | Creates an expression that returns the smallest `n` elements of an array.Note: Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined. |
| [arraySlice(arrayExpression, offset, length)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayslice_a349bee) | Creates an expression that returns a slice of an array from `offset` with `length` elements. |
| [arrayTransform(arrayExpression, elementAlias, transform)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraytransform_28967fa) | Creates an expression that applies a provided transformation to each element in an array. |
| [arrayTransformWithIndex(arrayExpression, elementAlias, indexAlias, transform)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraytransformwithindex_2f3b17f) | Creates an expression that applies a provided transformation to each element in an array, providing the element's index to the transformation expression. |
| [join(arrayExpression, delimiterExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#join_313e6aa) | Creates an expression that joins the elements of an array into a string. |
| [join(arrayExpression, delimiter)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#join_d088d29) | Creates an expression that joins the elements of an array into a string. |
| **function(arrayField, ...)** |   |
| [arrayGet(arrayField, offset)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayget_3f58471) | 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. |
| [arrayGet(arrayField, offsetExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayget_1904c9a) | 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. |
| **function(arrayFieldName, ...)** |   |
| [join(arrayFieldName, delimiter)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#join_478ef36) | Creates an expression that joins the elements of an array into a string. |
| [join(arrayFieldName, delimiterExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#join_829294c) | Creates an expression that joins the elements of an array into a string. |
| **function(base, ...)** |   |
| [pow(base, exponent)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#pow_e4a9e64) | Creates an expression that returns the value of the base expression raised to the power of the exponent expression. |
| [pow(base, exponent)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#pow_93eae7f) | Creates an expression that returns the value of the base expression raised to the power of the exponent. |
| [pow(base, exponent)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#pow_a237721) | Creates an expression that returns the value of the base field raised to the power of the exponent expression. |
| [pow(base, exponent)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#pow_f4d7908) | Creates an expression that returns the value of the base field raised to the power of the exponent. |
| **function(booleanExpr, ...)** |   |
| [countIf(booleanExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#countif_c5b8fb1) | Creates an aggregation that counts the number of stage inputs where the provided boolean expression evaluates to true. |
| [not(booleanExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#not_c5b8fb1) | Creates an expression that negates a filter condition. |
| **function(condition, ...)** |   |
| [conditional(condition, thenExpr, elseExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#conditional_07a206d) | Creates a conditional expression that evaluates to a 'then' expression if a condition is true and an 'else' expression if the condition is false. |
| [switchOn(condition, result, others)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#switchon_02b8caf) | Creates an expression that evaluates to the result corresponding to the first true condition. |
| **function(documentPath, ...)** |   |
| [documentId(documentPath)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#documentid_cef293c) | Creates an expression that returns the document ID from a path. |
| [parent_2(documentPath)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#parent_2_cef293c) | Creates an expression that returns the parent document reference of a document reference. |
| **function(documentPathExpr, ...)** |   |
| [documentId(documentPathExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#documentid_9a69021) | Creates an expression that returns the document ID from a path. |
| [parent_2(documentPathExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#parent_2_9a69021) | Creates an expression that returns the parent document reference of a document reference. |
| **function(element, ...)** |   |
| [notEqualAny(element, values)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#notequalany_c2c5bcb) | Creates an expression that checks if an expression is not equal to any of the provided values or expressions. |
| [notEqualAny(element, arrayExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#notequalany_16b2851) | Creates an expression that checks if an expression is not equal to any of the provided values or expressions. |
| **function(elements, ...)** |   |
| [array(elements)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#array_7d853aa) | Creates an expression that creates a Firestore array value from an input array. |
| [map(elements)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#map_ce5dee1) | Creates an expression that creates a Firestore map value from an input object. |
| **function(endExpression, ...)** |   |
| [timestampDiff(endExpression, startFieldName, unit)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampdiff_4370feb) | Creates an expression that calculates the difference between two timestamps. |
| [timestampDiff(endExpression, startExpression, unit)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampdiff_bc0830f) | Creates an expression that calculates the difference between two timestamps. |
| **function(endFieldName, ...)** |   |
| [timestampDiff(endFieldName, startFieldName, unit)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampdiff_f60102c) |   |
| [timestampDiff(endFieldName, startExpression, unit)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampdiff_6e54d92) | Creates an expression that calculates the difference between two timestamps. |
| **function(expr, ...)** |   |
| [abs(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#abs_005f3d4) | Creates an expression that computes the absolute value of a numeric value. |
| [ascending(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ascending_005f3d4) | Creates an [Ordering](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.ordering.md.txt#ordering_class) that sorts documents in ascending order based on an expression. |
| [byteLength(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#bytelength_005f3d4) | Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. |
| [countDistinct(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#countdistinct_3c28b08) | Creates an aggregation that counts the number of distinct values of a field. |
| [descending(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#descending_005f3d4) | Creates an [Ordering](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.ordering.md.txt#ordering_class) that sorts documents in descending order based on an expression. |
| [floor(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#floor_005f3d4) | Creates an expression that computes the floor of a numeric value. |
| [timestampToUnixMicros(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestamptounixmicros_005f3d4) | Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). |
| [timestampToUnixMillis(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestamptounixmillis_005f3d4) | Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). |
| [timestampToUnixSeconds(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestamptounixseconds_005f3d4) | Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). |
| [unixMicrosToTimestamp(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#unixmicrostotimestamp_005f3d4) | 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. |
| [unixMillisToTimestamp(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#unixmillistotimestamp_005f3d4) | 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. |
| [unixSecondsToTimestamp(expr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#unixsecondstotimestamp_005f3d4) | 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. |
| **function(expression, ...)** |   |
| [arrayAgg(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayagg_1138a27) | Creates an aggregation that collects all values of an expression across multiple stage inputs into an array. |
| [arrayAggDistinct(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayaggdistinct_1138a27) | Creates an aggregation that collects all distinct values of an expression across multiple stage inputs into an array. |
| [arraySum(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraysum_1138a27) | Creates an expression that computes the sum of the elements in an array. |
| [average(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#average_1138a27) | Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs. |
| [ceil(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ceil_1138a27) | Creates an expression that computes the ceiling of a numeric value. |
| [coalesce(expression, replacement, others)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#coalesce_00859cb) | Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument. |
| [collectionId(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#collectionid_1138a27) | Creates an expression that returns the collection ID from a path. |
| [count(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#count_1138a27) | Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided expression. |
| [divide(expression, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#divide_01df3cf) | Creates an expression that divides an expression by a constant value. |
| [equal(expression, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#equal_01df3cf) | Creates an expression that checks if an expression is equal to a constant value. |
| [equalAny(expression, values)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#equalany_7e759b5) | Creates an expression that checks if an expression, when evaluated, is equal to any of the provided values or expressions. |
| [equalAny(expression, arrayExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#equalany_214ce68) | Creates an expression that checks if an expression is equal to any of the provided values. |
| [exp(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#exp_1138a27) | Creates an expression that computes e to the power of the expression's result. |
| [first(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#first_1138a27) | Creates an aggregation that finds the first value of an expression across multiple stage inputs. |
| [greaterThan(expression, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#greaterthan_01df3cf) | Creates an expression that checks if an expression is greater than a constant value. |
| [greaterThanOrEqual(expression, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#greaterthanorequal_01df3cf) | Creates an expression that checks if an expression is greater than or equal to a constant value. |
| [isType(expression, type)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#istype_e58f382) | Creates an expression that checks if the result of an expression is of the given type. |
| [last(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#last_1138a27) | Creates an aggregation that finds the last value of an expression across multiple stage inputs. |
| [length_2(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#length_2_1138a27) | Creates an expression that calculates the length of a string, array, map, vector, or bytes. |
| [lessThan(expression, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#lessthan_01df3cf) | Creates an expression that checks if an expression is less than a constant value. |
| [lessThanOrEqual(expression, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#lessthanorequal_01df3cf) | Creates an expression that checks if an expression is less than or equal to a constant value. |
| [ln(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ln_1138a27) | Creates an expression that computes the natural logarithm of a numeric value. |
| [log(expression, base)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#log_ac183e2) | Creates an expression that computes the logarithm of an expression to a given base. |
| [log(expression, base)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#log_1894737) | Creates an expression that computes the logarithm of an expression to a given base. |
| [log10(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#log10_1138a27) | Creates an expression that computes the base-10 logarithm of a numeric value. |
| [ltrim(expression, valueToTrim)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ltrim_775e2f2) | Trims whitespace or a specified set of characters/bytes from the beginning of a string or byte array. |
| [maximum(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#maximum_1138a27) | Creates an aggregation that finds the maximum value of an expression across multiple stage inputs. |
| [minimum(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#minimum_1138a27) | Creates an aggregation that finds the minimum value of an expression across multiple stage inputs. |
| [mod(expression, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mod_01df3cf) | Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. |
| [notEqual(expression, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#notequal_01df3cf) | Creates an expression that checks if an expression is not equal to a constant value. |
| [round(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#round_1138a27) | Creates an expression that rounds a numeric value to the nearest whole number. |
| [round(expression, decimalPlaces)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#round_a3a92d0) | Creates an expression that rounds a numeric value to the specified number of decimal places. |
| [rtrim(expression, valueToTrim)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#rtrim_775e2f2) | Trims whitespace or a specified set of characters/bytes from the end of a string or byte array. |
| [split(expression, delimiter)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#split_5b5612b) | Creates an expression that splits a string into an array of substrings based on the provided delimiter. |
| [split(expression, delimiter)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#split_5a171ed) | Creates an expression that splits a string into an array of substrings based on the provided delimiter. |
| [sqrt(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#sqrt_1138a27) | Creates an expression that computes the square root of a numeric value. |
| [stringIndexOf(expression, search)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringindexof_6dfca5f) | Creates an expression that finds the index of the first occurrence of a substring or byte sequence. |
| [stringRepeat(expression, repetitions)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringrepeat_a55ba16) | Creates an expression that repeats a string or byte array a specified number of times. |
| [stringReplaceAll(expression, find, replacement)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringreplaceall_197ecbe) | Creates an expression that replaces all occurrences of a substring or byte sequence with a replacement. |
| [stringReplaceOne(expression, find, replacement)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringreplaceone_197ecbe) | Creates an expression that replaces the first occurrence of a substring or byte sequence with a replacement. |
| [subtract(expression, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#subtract_01df3cf) | Creates an expression that subtracts a constant value from an expression. |
| [sum(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#sum_1138a27) | Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs. |
| [trunc(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#trunc_1138a27) | Creates an expression that truncates the numeric value of an expression to an integer. |
| [trunc(expression, decimalPlaces)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#trunc_a3a92d0) | Creates an expression that truncates a numeric value to the specified number of decimal places. |
| [type(expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#type_1138a27) | Creates an expression that returns the data type of an expression's result. |
| **function(field, ...)** |   |
| [isAbsent(field)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#isabsent_0fb8cd4) | Creates an expression that returns `true` if a field is absent. Otherwise, returns `false` even if the field value is `null`. |
| [reverse(field)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#reverse_0fb8cd4) | Creates an expression that reverses a string value in the specified field. |
| [stringReverse(field)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringreverse_0fb8cd4) | Creates an expression that reverses a string value in the specified field. |
| [substring(field, position, length)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#substring_0d9573a) | Creates an expression that returns a substring of a string or byte array. |
| [substring(field, position, length)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#substring_05cb14e) | Creates an expression that returns a substring of a string or byte array. |
| **function(fieldName, ...)** |   |
| [abs(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#abs_e5b0480) | Creates an expression that computes the absolute value of a numeric value. |
| [add(fieldName, second)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#add_b75bb8b) | Creates an expression that adds a field's value to an expression. |
| [arrayAgg(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayagg_e5b0480) | Creates an aggregation that collects all values of a field across multiple stage inputs into an array. |
| [arrayAggDistinct(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayaggdistinct_e5b0480) | Creates an aggregation that collects all distinct values of a field across multiple stage inputs into an array. |
| [arrayContains(fieldName, element)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontains_aaace4a) | Creates an expression that checks if a field's array value contains a specific element. |
| [arrayContains(fieldName, element)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontains_999590f) | Creates an expression that checks if a field's array value contains a specific value. |
| [arrayContainsAll(fieldName, values)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontainsall_8060b23) | Creates an expression that checks if a field's array value contains all the specified values or expressions. |
| [arrayContainsAll(fieldName, arrayExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontainsall_48da8d9) | Creates an expression that checks if a field's array value contains all the specified values or expressions. |
| [arrayContainsAny(fieldName, values)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontainsany_8060b23) | Creates an expression that checks if a field's array value contains any of the specified elements. |
| [arrayContainsAny(fieldName, values)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraycontainsany_1b4f7cd) | Creates an expression that checks if a field's array value contains any of the specified elements. |
| [arrayFilter(fieldName, alias, filter)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayfilter_ab67868) | Creates an expression that filters an array using a provided alias and predicate expression. |
| [arrayFirst(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayfirst_e5b0480) | Creates an expression that returns the first element of an array. |
| [arrayFirstN(fieldName, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayfirstn_597a4d9) | Creates an expression that returns the first `n` elements of an array. |
| [arrayFirstN(fieldName, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayfirstn_1a86a2c) | Creates an expression that returns the first `n` elements of an array. |
| [arrayIndexOf(fieldName, search)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayindexof_5e4c2c3) | Creates an expression that returns the first index of the search value in an array. Returns -1 if the value is not found. |
| [arrayIndexOfAll(fieldName, search)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayindexofall_5e4c2c3) | Creates an expression that returns all indices of the search value in an array. |
| [arrayLast(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraylast_e5b0480) | Creates an expression that returns the last element of an array. |
| [arrayLastIndexOf(fieldName, search)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraylastindexof_5e4c2c3) | Creates an expression that returns the last index of the search value in an array. Returns -1 if the value is not found. |
| [arrayLastN(fieldName, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraylastn_597a4d9) | Creates an expression that returns the last `n` elements of an array. |
| [arrayLastN(fieldName, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraylastn_1a86a2c) | Creates an expression that returns the last `n` elements of an array. |
| [arrayLength(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraylength_e5b0480) | Creates an expression that calculates the length of an array in a specified field. |
| [arrayMaximum(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraymaximum_e5b0480) | Creates an expression that returns the maximum value in an array. |
| [arrayMaximumN(fieldName, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraymaximumn_597a4d9) | Creates an expression that returns the largest `n` elements of an array.Note: Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined. |
| [arrayMaximumN(fieldName, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraymaximumn_1a86a2c) | Creates an expression that returns the largest `n` elements of an array.Note: Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined. |
| [arrayMinimum(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayminimum_e5b0480) | Creates an expression that returns the minimum value in an array. |
| [arrayMinimumN(fieldName, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayminimumn_597a4d9) | Creates an expression that returns the smallest `n` elements of an array.Note: Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined. |
| [arrayMinimumN(fieldName, n)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayminimumn_1a86a2c) | Creates an expression that returns the smallest `n` elements of an array.Note: Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined. |
| [arraySlice(fieldName, offset, length)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayslice_821aa43) | Creates an expression that returns a slice of an array from `offset` with `length` elements. |
| [arraySum(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraysum_e5b0480) | Creates an expression that computes the sum of the elements in an array. |
| [arrayTransform(fieldName, elementAlias, transform)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraytransform_328a090) | Creates an expression that applies a provided transformation to each element in an array. |
| [arrayTransformWithIndex(fieldName, elementAlias, indexAlias, transform)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arraytransformwithindex_e6629b2) | Creates an expression that applies a provided transformation to each element in an array, providing the element's index to the transformation expression. |
| [ascending(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ascending_e5b0480) | Creates an [Ordering](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.ordering.md.txt#ordering_class) that sorts documents in ascending order based on a field. |
| [average(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#average_e5b0480) | Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs. |
| [byteLength(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#bytelength_e5b0480) | 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. |
| [ceil(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ceil_e5b0480) | Creates an expression that computes the ceiling of a numeric value. |
| [charLength(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#charlength_e5b0480) | Creates an expression that calculates the character length of a string field in UTF8. |
| [coalesce(fieldName, replacement, others)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#coalesce_249958e) | Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument. |
| [collectionId(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#collectionid_e5b0480) | Creates an expression that returns the collection ID from a path. |
| [concat(fieldName, second, others)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#concat_828272e) | Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed. |
| [cosineDistance(fieldName, vector)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#cosinedistance_463a23e) | Calculates the Cosine distance between a field's vector value and a literal vector value. |
| [cosineDistance(fieldName, vectorExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#cosinedistance_ed766a1) | Calculates the Cosine distance between a field's vector value and a vector expression. |
| [count(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#count_e5b0480) | Creates an aggregation that counts the number of stage inputs where the input field exists. |
| [descending(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#descending_e5b0480) | Creates an [Ordering](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.ordering.md.txt#ordering_class) that sorts documents in descending order based on a field. |
| [divide(fieldName, expressions)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#divide_cf36e43) | Creates an expression that divides a field's value by an expression. |
| [divide(fieldName, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#divide_65e2f32) | Creates an expression that divides a field's value by a constant value. |
| [dotProduct(fieldName, vector)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#dotproduct_463a23e) | Calculates the dot product between a field's vector value and a double array. |
| [dotProduct(fieldName, vectorExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#dotproduct_ed766a1) | Calculates the dot product between a field's vector value and a vector expression. |
| [endsWith(fieldName, suffix)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#endswith_05ca3b0) | Creates an expression that checks if a field's value ends with a given postfix. |
| [endsWith(fieldName, suffix)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#endswith_8fc0ebc) | Creates an expression that checks if a field's value ends with a given postfix. |
| [equal(fieldName, expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#equal_1e91657) | Creates an expression that checks if a field's value is equal to an expression. |
| [equal(fieldName, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#equal_65e2f32) | Creates an expression that checks if a field's value is equal to a constant value. |
| [equalAny(fieldName, values)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#equalany_8060b23) | Creates an expression that checks if a field's value is equal to any of the provided values or expressions. |
| [equalAny(fieldName, arrayExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#equalany_48da8d9) | Creates an expression that checks if a field's value is equal to any of the provided values or expressions. |
| [euclideanDistance(fieldName, vector)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#euclideandistance_463a23e) | Calculates the Euclidean distance between a field's vector value and a double array. |
| [euclideanDistance(fieldName, vectorExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#euclideandistance_ed766a1) | Calculates the Euclidean distance between a field's vector value and a vector expression. |
| [exists(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#exists_e5b0480) | Creates an expression that checks if a field exists. |
| [exp(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#exp_e5b0480) | Creates an expression that computes e to the power of the expression's result. |
| [first(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#first_e5b0480) | Creates an aggregation that finds the first value of a field across multiple stage inputs. |
| [floor(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#floor_e5b0480) | Creates an expression that computes the floor of a numeric value. |
| [geoDistance(fieldName, location)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#geodistance_ea237a8) | Evaluates to the distance in meters between the location in the specified field and the query location. |
| [greaterThan(fieldName, expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#greaterthan_1e91657) | Creates an expression that checks if a field's value is greater than an expression. |
| [greaterThan(fieldName, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#greaterthan_65e2f32) | Creates an expression that checks if a field's value is greater than a constant value. |
| [greaterThanOrEqual(fieldName, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#greaterthanorequal_2e16acb) | Creates an expression that checks if a field's value is greater than or equal to an expression. |
| [greaterThanOrEqual(fieldName, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#greaterthanorequal_65e2f32) | Creates an expression that checks if a field's value is greater than or equal to a constant value. |
| [isType(fieldName, type)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#istype_ec95173) | Creates an expression that checks if the value in the specified field is of the given type. |
| [last(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#last_e5b0480) | Creates an aggregation that finds the last value of a field across multiple stage inputs. |
| [length_2(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#length_2_e5b0480) | Creates an expression that calculates the length of a string, array, map, vector, or bytes. |
| [lessThan(fieldName, expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#lessthan_1e91657) | Creates an expression that checks if a field's value is less than an expression. |
| [lessThan(fieldName, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#lessthan_65e2f32) | Creates an expression that checks if a field's value is less than a constant value. |
| [lessThanOrEqual(fieldName, expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#lessthanorequal_1e91657) | Creates an expression that checks if a field's value is less than or equal to an expression. |
| [lessThanOrEqual(fieldName, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#lessthanorequal_65e2f32) | Creates an expression that checks if a field's value is less than or equal to a constant value. |
| [like(fieldName, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#like_67f7432) | Creates an expression that performs a case-sensitive wildcard string comparison against a field. |
| [like(fieldName, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#like_cb1318d) | Creates an expression that performs a case-sensitive wildcard string comparison against a field. |
| [ln(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ln_e5b0480) | Creates an expression that computes the natural logarithm of a numeric value. |
| [log(fieldName, base)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#log_a89e21b) | Creates an expression that computes the logarithm of a field to a given base. |
| [log(fieldName, base)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#log_805b11f) | Creates an expression that computes the logarithm of a field to a given base. |
| [log10(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#log10_e5b0480) | Creates an expression that computes the base-10 logarithm of a numeric value. |
| [logicalMaximum(fieldName, second, others)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#logicalmaximum_828272e) | Creates an expression that returns the largest value between multiple input expressions or literal values. Based on Firestore's value type ordering. |
| [logicalMinimum(fieldName, second, others)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#logicalminimum_828272e) | 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. |
| [ltrim(fieldName, valueToTrim)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ltrim_c0e3211) | Trims whitespace or a specified set of characters/bytes from the beginning of a string or byte array. |
| [mapGet(fieldName, subField)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapget_06663cf) | Accesses a value from a map (object) field using the provided key. |
| [maximum(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#maximum_e5b0480) | Creates an aggregation that finds the maximum value of a field across multiple stage inputs. |
| [minimum(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#minimum_e5b0480) | Creates an aggregation that finds the minimum value of a field across multiple stage inputs. |
| [mod(fieldName, expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mod_1e91657) | Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. |
| [mod(fieldName, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mod_65e2f32) | Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. |
| [multiply(fieldName, second)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#multiply_b75bb8b) | Creates an expression that multiplies a field's value by an expression. |
| [notEqual(fieldName, expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#notequal_1e91657) | Creates an expression that checks if a field's value is not equal to an expression. |
| [notEqual(fieldName, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#notequal_65e2f32) | Creates an expression that checks if a field's value is not equal to a constant value. |
| [notEqualAny(fieldName, values)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#notequalany_8060b23) | Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. |
| [notEqualAny(fieldName, arrayExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#notequalany_48da8d9) | Creates an expression that checks if a field's value is not equal to any of the values in the evaluated expression. |
| [regexContains(fieldName, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexcontains_67f7432) | Creates an expression that checks if a string field contains a specified regular expression as a substring. |
| [regexContains(fieldName, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexcontains_cb1318d) | Creates an expression that checks if a string field contains a specified regular expression as a substring. |
| [regexFind(fieldName, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexfind_67f7432) | Creates an expression that returns the first substring of a string field that matches a specified regular expression.This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax. |
| [regexFind(fieldName, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexfind_cb1318d) | Creates an expression that returns the first substring of a string field that matches a specified regular expression.This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax. |
| [regexFindAll(fieldName, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexfindall_67f7432) | Creates an expression that evaluates to a list of all substrings in a string field that match a specified regular expression.This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax. |
| [regexFindAll(fieldName, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexfindall_cb1318d) | Creates an expression that evaluates to a list of all substrings in a string field that match a specified regular expression.This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax. |
| [regexMatch(fieldName, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexmatch_67f7432) | Creates an expression that checks if a string field matches a specified regular expression. |
| [regexMatch(fieldName, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexmatch_cb1318d) | Creates an expression that checks if a string field matches a specified regular expression. |
| [round(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#round_e5b0480) | Creates an expression that rounds a numeric value to the nearest whole number. |
| [round(fieldName, decimalPlaces)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#round_07d0cf0) | Creates an expression that rounds a numeric value to the specified number of decimal places. |
| [rtrim(fieldName, valueToTrim)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#rtrim_c0e3211) | Trims whitespace or a specified set of characters/bytes from the end of a string or byte array. |
| [split(fieldName, delimiter)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#split_2cfdd37) | Creates an expression that splits the value of a field on the provided delimiter. |
| [split(fieldName, delimiter)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#split_f4fe06a) | Creates an expression that splits the value of a field on the provided delimiter. |
| [sqrt(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#sqrt_e5b0480) | Creates an expression that computes the square root of a numeric value. |
| [startsWith(fieldName, prefix)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#startswith_89325cc) | Creates an expression that checks if a field's value starts with a given prefix. |
| [startsWith(fieldName, prefix)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#startswith_266c338) | Creates an expression that checks if a field's value starts with a given prefix. |
| [stringConcat(fieldName, secondString, otherStrings)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringconcat_d80077e) | Creates an expression that concatenates string functions, fields or constants together. |
| [stringContains(fieldName, substring)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringcontains_5b94cfe) | Creates an expression that checks if a string field contains a specified substring. |
| [stringContains(fieldName, substring)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringcontains_ac3ba47) | Creates an expression that checks if a string field contains a substring specified by an expression. |
| [stringIndexOf(fieldName, search)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringindexof_6c4650e) | Creates an expression that finds the index of the first occurrence of a substring or byte sequence. |
| [stringRepeat(fieldName, repetitions)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringrepeat_e144a59) | Creates an expression that repeats a string or byte array a specified number of times. |
| [stringReplaceAll(fieldName, find, replacement)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringreplaceall_b0db15f) | Creates an expression that replaces all occurrences of a substring or byte sequence with a replacement. |
| [stringReplaceOne(fieldName, find, replacement)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringreplaceone_b0db15f) | Creates an expression that replaces the first occurrence of a substring or byte sequence with a replacement. |
| [subtract(fieldName, expression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#subtract_1e91657) | Creates an expression that subtracts an expression from a field's value. |
| [subtract(fieldName, value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#subtract_65e2f32) | Creates an expression that subtracts a constant value from a field's value. |
| [sum(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#sum_e5b0480) | Creates an aggregation that calculates the sum of a field's values across multiple stage inputs. |
| [timestampAdd(fieldName, unit, amount)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampadd_3b0a297) | Creates an expression that adds a specified amount of time to a timestamp represented by a field. |
| [timestampExtract(fieldName, part, timezone)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampextract_a51c205) | Creates an expression that extracts a specified part from a timestamp. |
| [timestampExtract(fieldName, part, timezone)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampextract_2d51eac) | Creates an expression that extracts a specified part from a timestamp. |
| [timestampSubtract(fieldName, unit, amount)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampsubtract_3b0a297) | Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. |
| [timestampToUnixMicros(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestamptounixmicros_e5b0480) | Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). |
| [timestampToUnixMillis(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestamptounixmillis_e5b0480) | Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). |
| [timestampToUnixSeconds(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestamptounixseconds_e5b0480) | Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). |
| [timestampTruncate(fieldName, granularity, timezone)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestamptruncate_b6c7512) | Creates an expression that truncates a timestamp to a specified granularity. |
| [timestampTruncate(fieldName, granularity, timezone)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestamptruncate_ed83d46) | Creates an expression that truncates a timestamp to a specified granularity. |
| [toLower(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#tolower_e5b0480) | Creates an expression that converts a string field to lowercase. |
| [toUpper(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#toupper_e5b0480) | Creates an expression that converts a string field to uppercase. |
| [trim(fieldName, valueToTrim)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#trim_c9f90ee) | Creates an expression that removes leading and trailing whitespace from a string or byte array. |
| [trunc(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#trunc_e5b0480) | Creates an expression that truncates the numeric value of a field to an integer. |
| [trunc(fieldName, decimalPlaces)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#trunc_07d0cf0) | Creates an expression that truncates a numeric expression to the specified number of decimal places. |
| [type(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#type_e5b0480) | Creates an expression that returns the data type of the data in the specified field. |
| [unixMicrosToTimestamp(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#unixmicrostotimestamp_e5b0480) | 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. |
| [unixMillisToTimestamp(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#unixmillistotimestamp_e5b0480) | 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. |
| [unixSecondsToTimestamp(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#unixsecondstotimestamp_e5b0480) | 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. |
| [vectorLength(fieldName)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#vectorlength_e5b0480) | Creates an expression that calculates the length of a Firestore Vector represented by a field. |
| **function(first, ...)** |   |
| [add(first, second)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#add_846ca1b) | Creates an expression that adds two expressions together. |
| [and(first, second, more)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#and_e0c48bd) | Creates an expression that performs a logical 'AND' operation on multiple filter conditions. |
| [concat(first, second, others)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#concat_83be015) | Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed. |
| [logicalMaximum(first, second, others)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#logicalmaximum_83be015) | Creates an expression that returns the largest value between multiple input expressions or literal values. Based on Firestore's value type ordering. |
| [logicalMinimum(first, second, others)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#logicalminimum_83be015) | Creates an expression that returns the smallest value between multiple input expressions and literal values. Based on Firestore's value type ordering. |
| [multiply(first, second)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#multiply_846ca1b) | Creates an expression that multiplies two expressions together. |
| [nor(first, second, more)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#nor_e0c48bd) | Creates an expression that performs a logical 'NOR' operation on multiple filter conditions. |
| [or(first, second, more)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#or_e0c48bd) | Creates an expression that performs a logical 'OR' operation on multiple filter conditions. |
| [xor(first, second, additionalConditions)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#xor_8197113) | Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple BooleanExpressions. |
| **function(firstArray, ...)** |   |
| [arrayConcat(firstArray, secondArray, otherArrays)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayconcat_c00d5d7) | Creates an expression that concatenates an array expression with other arrays. |
| **function(firstArrayField, ...)** |   |
| [arrayConcat(firstArrayField, secondArray, otherArrays)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#arrayconcat_f92063d) | Creates an expression that concatenates a field's array value with other arrays. |
| **function(firstMap, ...)** |   |
| [mapMerge(firstMap, secondMap, otherMaps)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapmerge_cfe77ce) | Creates an expression that merges multiple map values. |
| **function(firstString, ...)** |   |
| [stringConcat(firstString, secondString, otherStrings)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringconcat_8a8d1b6) | Creates an expression that concatenates string expressions together. |
| **function(ifExpr, ...)** |   |
| [ifAbsent(ifExpr, elseExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ifabsent_0e6d161) | Creates an expression that returns the `elseExpr` argument if `ifExpr` is absent, else return the result of the `ifExpr` argument evaluation. |
| [ifAbsent(ifExpr, elseValue)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ifabsent_c34e5ed) | Creates an expression that returns the `elseValue` argument if `ifExpr` is absent, else return the result of the `ifExpr` argument evaluation. |
| [ifNull(ifExpr, elseExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ifnull_0e6d161) | Creates an expression that returns the `elseExpr` argument if `ifExpr` is null, else return the result of the `ifExpr` argument evaluation. |
| [ifNull(ifExpr, elseValue)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ifnull_c34e5ed) | Creates an expression that returns the `elseValue` argument if `ifExpr` is null, else return the result of the `ifExpr` argument evaluation. |
| **function(ifFieldName, ...)** |   |
| [ifAbsent(ifFieldName, elseExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ifabsent_e6dabea) | Creates an expression that returns the `elseExpr` argument if `ifFieldName` is absent, else return the value of the field. |
| [ifAbsent(ifFieldName, elseValue)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ifabsent_d8f2823) | Creates an expression that returns the `elseValue` argument if `ifFieldName` is absent, else return the value of the field. |
| [ifNull(ifFieldName, elseExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ifnull_e6dabea) | Creates an expression that returns the `elseExpr` argument if `ifFieldName` field is null, else return the value of the field. |
| [ifNull(ifFieldName, elseValue)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#ifnull_587c2f0) | Creates an expression that returns the `elseValue` argument if `ifFieldName` field is null, else return the value of the field. |
| **function(input, ...)** |   |
| [substring(input, position, length)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#substring_e6e0aa3) | Creates an expression that returns a substring of a string or byte array. |
| [substring(input, position, length)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#substring_ab56dc6) | Creates an expression that returns a substring of a string or byte array. |
| **function(left, ...)** |   |
| [divide(left, right)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#divide_b3c3382) | Creates an expression that divides two expressions. |
| [equal(left, right)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#equal_b3c3382) | Creates an expression that checks if two expressions are equal. |
| [greaterThan(left, right)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#greaterthan_b3c3382) | Creates an expression that checks if the first expression is greater than the second expression. |
| [greaterThanOrEqual(left, right)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#greaterthanorequal_b3c3382) | Creates an expression that checks if the first expression is greater than or equal to the second expression. |
| [lessThan(left, right)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#lessthan_b3c3382) | Creates an expression that checks if the first expression is less than the second expression. |
| [lessThanOrEqual(left, right)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#lessthanorequal_b3c3382) | Creates an expression that checks if the first expression is less than or equal to the second expression. |
| [mod(left, right)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mod_b3c3382) | Creates an expression that calculates the modulo (remainder) of dividing two expressions. |
| [notEqual(left, right)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#notequal_b3c3382) | Creates an expression that checks if two expressions are not equal. |
| [pipelineResultEqual(left, right)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#pipelineresultequal_707a755) | Test equality of two PipelineResults. |
| [subtract(left, right)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#subtract_b3c3382) | Creates an expression that subtracts two expressions. |
| **function(mapExpr, ...)** |   |
| [mapRemove(mapExpr, key)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapremove_23c7d51) | Creates an expression that removes a key from the map produced by evaluating an expression. |
| [mapRemove(mapExpr, keyExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapremove_9fbcaa3) | Creates an expression that removes a key from the map produced by evaluating an expression. |
| **function(mapExpression, ...)** |   |
| [mapEntries(mapExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapentries_9cf124c) | Creates an expression that returns the entries of a map as an array of maps, where each map contains a `"k"` property for the key and a `"v"` property for the value. For example: `[{ k: "key1", v: "value1" }, ...]`. |
| [mapGet(mapExpression, subField)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapget_688c050) | Accesses a value from a map (object) expression using the provided key. |
| [mapKeys(mapExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapkeys_9cf124c) | Creates an expression that returns the keys of a map. |
| [mapSet(mapExpression, key, value, moreKeyValues)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapset_45b48ff) | Creates an expression that returns a new map with the specified entries added or updated. |
| [mapValues(mapExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapvalues_9cf124c) | Creates an expression that returns the values of a map. |
| **function(mapField, ...)** |   |
| [mapEntries(mapField)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapentries_83ad836) | Creates an expression that returns the entries of a map as an array of maps, where each map contains a `"k"` property for the key and a `"v"` property for the value. For example: `[{ k: "key1", v: "value1" }, ...]`. |
| [mapKeys(mapField)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapkeys_83ad836) | Creates an expression that returns the keys of a map. |
| [mapMerge(mapField, secondMap, otherMaps)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapmerge_70a564b) | Creates an expression that merges multiple map values. |
| [mapRemove(mapField, key)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapremove_bd5726e) | Creates an expression that removes a key from the map at the specified field name. |
| [mapRemove(mapField, keyExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapremove_8406d13) | Creates an expression that removes a key from the map at the specified field name. |
| [mapSet(mapField, key, value, moreKeyValues)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapset_baadc2a) | Creates an expression that returns a new map with the specified entries added or updated. |
| [mapValues(mapField)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#mapvalues_83ad836) | Creates an expression that returns the values of a map. |
| **function(name, ...)** |   |
| [field(name)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#field_1eaaff4) | Creates a [Field](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.field.md.txt#field_class) 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"). |
| [variable(name)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#variable_1eaaff4) | Creates an expression that retrieves the value of a variable bound via `define()`. |
| **function(options, ...)** |   |
| [execute(options)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#execute_9e87e31) | Executes a pipeline and returns a Promise that represents 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 [PipelineSnapshot](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesnapshot.md.txt#pipelinesnapshot_class) that contains a list of [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) objects. Each [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#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](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) represents a single document. - If there is an aggregation, only a single [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) is returned, representing the aggregated results over the entire dataset. - If there is an aggregation stage with grouping, each [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) represents a distinct group and its associated aggregated values. |
| [subcollection(options)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#subcollection_104dbc5) | Creates a new Pipeline targeted at a subcollection relative to the current document context. This creates a pipeline without a database instance, suitable for embedding as a subquery. If executed directly, this pipeline will fail. |
| **function(path, ...)** |   |
| [field(path)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#field_34ee07d) | Creates a [Field](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.field.md.txt#field_class) instance representing the field at the given path. |
| [subcollection(path)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#subcollection_fe1f8e4) | Creates a new Pipeline targeted at a subcollection relative to the current document context. This creates a pipeline without a database instance, suitable for embedding as a subquery. If executed directly, this pipeline will fail. |
| **function(pipeline, ...)** |   |
| [execute(pipeline)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#execute_01df620) | Executes a pipeline and returns a Promise that represents 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 [PipelineSnapshot](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesnapshot.md.txt#pipelinesnapshot_class) that contains a list of [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) objects. Each [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#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](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) represents a single document. - If there is an aggregation, only a single [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) is returned, representing the aggregated results over the entire dataset. - If there is an aggregation stage with grouping, each [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) represents a distinct group and its associated aggregated values. |
| **function(rquery, ...)** |   |
| [documentMatches(rquery)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#documentmatches_d7a12c2) | Perform a full-text search on all indexed search fields in the document. |
| **function(stringExpression, ...)** |   |
| [charLength(stringExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#charlength_c25a54a) | Creates an expression that calculates the character length of a string expression in UTF-8. |
| [endsWith(stringExpression, suffix)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#endswith_0a0b889) | Creates an expression that checks if a string expression ends with a given postfix. |
| [endsWith(stringExpression, suffix)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#endswith_13aee0d) | Creates an expression that checks if a string expression ends with a given postfix. |
| [like(stringExpression, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#like_a84c581) | Creates an expression that performs a case-sensitive wildcard string comparison. |
| [like(stringExpression, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#like_b534848) | Creates an expression that performs a case-sensitive wildcard string comparison. |
| [regexContains(stringExpression, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexcontains_a84c581) | Creates an expression that checks if a string expression contains a specified regular expression as a substring. |
| [regexContains(stringExpression, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexcontains_b534848) | Creates an expression that checks if a string expression contains a specified regular expression as a substring. |
| [regexFind(stringExpression, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexfind_a84c581) | Creates an expression that returns the first substring of a string expression that matches a specified regular expression.This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax. |
| [regexFind(stringExpression, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexfind_b534848) | Creates an expression that returns the first substring of a string expression that matches a specified regular expression.This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax. |
| [regexFindAll(stringExpression, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexfindall_a84c581) | Creates an expression that evaluates to a list of all substrings in a string expression that match a specified regular expression.This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax. |
| [regexFindAll(stringExpression, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexfindall_b534848) | Creates an expression that evaluates to a list of all substrings in a string expression that match a specified regular expression.This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax. |
| [regexMatch(stringExpression, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexmatch_a84c581) | Creates an expression that checks if a string expression matches a specified regular expression. |
| [regexMatch(stringExpression, pattern)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#regexmatch_b534848) | Creates an expression that checks if a string expression matches a specified regular expression. |
| [reverse(stringExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#reverse_c25a54a) | Creates an expression that reverses a string. |
| [startsWith(stringExpression, prefix)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#startswith_75c3dbb) | Creates an expression that checks if a string expression starts with a given prefix. |
| [startsWith(stringExpression, prefix)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#startswith_52f218a) | Creates an expression that checks if a string expression starts with a given prefix. |
| [stringContains(stringExpression, substring)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringcontains_3e9ff32) | Creates an expression that checks if a string expression contains a specified substring. |
| [stringContains(stringExpression, substring)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringcontains_cc6ee02) | Creates an expression that checks if a string expression contains a substring specified by another expression. |
| [stringReverse(stringExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stringreverse_c25a54a) | Creates an expression that reverses a string. |
| [toLower(stringExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#tolower_c25a54a) | Creates an expression that converts a string expression to lowercase. |
| [toUpper(stringExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#toupper_c25a54a) | Creates an expression that converts a string expression to uppercase. |
| [trim(stringExpression, valueToTrim)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#trim_dd54322) | Creates an expression that removes leading and trailing characters from a string or byte array expression. |
| **function(timestamp, ...)** |   |
| [timestampAdd(timestamp, unit, amount)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampadd_98418f9) | Creates an expression that adds a specified amount of time to a timestamp. |
| [timestampAdd(timestamp, unit, amount)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampadd_06ef927) | Creates an expression that adds a specified amount of time to a timestamp. |
| [timestampSubtract(timestamp, unit, amount)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampsubtract_98418f9) | Creates an expression that subtracts a specified amount of time from a timestamp. |
| [timestampSubtract(timestamp, unit, amount)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampsubtract_06ef927) | Creates an expression that subtracts a specified amount of time from a timestamp. |
| **function(timestampExpression, ...)** |   |
| [timestampExtract(timestampExpression, part, timezone)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampextract_b2f8f48) | Creates an expression that extracts a specified part from a timestamp. |
| [timestampExtract(timestampExpression, part, timezone)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestampextract_73e0311) | Creates an expression that extracts a specified part from a timestamp. |
| [timestampTruncate(timestampExpression, granularity, timezone)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestamptruncate_ad5d843) | Creates an expression that truncates a timestamp to a specified granularity. |
| [timestampTruncate(timestampExpression, granularity, timezone)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timestamptruncate_d6ab2a4) | Creates an expression that truncates a timestamp to a specified granularity. |
| **function(tryExpr, ...)** |   |
| [ifError(tryExpr, catchExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#iferror_a99a327) | Creates an expression that returns the `catch` argument if there is an error, else return the result of the `try` argument evaluation.This overload is useful when a BooleanExpression is required. |
| [ifError(tryExpr, catchExpr)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#iferror_756c12e) | Creates an expression that returns the `catch` argument if there is an error, else return the result of the `try` argument evaluation. |
| [ifError(tryExpr, catchValue)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#iferror_dc532f9) | Creates an expression that returns the `catch` argument if there is an error, else return the result of the `try` argument evaluation. |
| **function(value, ...)** |   |
| [constant(value, options)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#constant_27f5011) | Creates a `Constant` instance for a number value. |
| [constant(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#constant_6dac335) | Creates a `Constant` instance for a VectorValue value. |
| [constant(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#constant_7c807cd) | Creates a `Constant` instance for a string value. |
| [constant(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#constant_b2e4f8d) | Creates a `BooleanExpression` instance for a boolean value. |
| [constant(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#constant_73ebd84) | Creates a `Constant` instance for a null value. |
| [constant(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#constant_72a76cb) | Creates a `Constant` instance for a GeoPoint value. |
| [constant(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#constant_000477d) | Creates a `Constant` instance for a Timestamp value. |
| [constant(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#constant_5131bf7) | Creates a `Constant` instance for a Date value. |
| [constant(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#constant_fdf565d) | Creates a `Constant` instance for a Bytes value. |
| [constant(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#constant_bcd2b0b) | Creates a `Constant` instance for a DocumentReference value. |
| [exists(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#exists_f3daf14) | Creates an expression that checks if a field exists. |
| [isAbsent(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#isabsent_f3daf14) | Creates an expression that returns `true` if a value is absent. Otherwise, returns `false` even if the value is `null`. |
| [isError(value)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#iserror_f3daf14) | Creates an expression that checks if a given expression produces an error. |
| **function(vectorExpression, ...)** |   |
| [cosineDistance(vectorExpression, vector)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#cosinedistance_3a80317) | Calculates the Cosine distance between a vector expression and a vector literal. |
| [cosineDistance(vectorExpression, otherVectorExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#cosinedistance_17b5bcc) | Calculates the Cosine distance between two vector expressions. |
| [dotProduct(vectorExpression, vector)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#dotproduct_3a80317) | Calculates the dot product between a vector expression and a double array. |
| [dotProduct(vectorExpression, otherVectorExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#dotproduct_17b5bcc) | Calculates the dot product between two vector expressions. |
| [euclideanDistance(vectorExpression, vector)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#euclideandistance_3a80317) | Calculates the Euclidean distance between a vector expression and a double array. |
| [euclideanDistance(vectorExpression, otherVectorExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#euclideandistance_17b5bcc) | Calculates the Euclidean distance between two vector expressions. |
| [vectorLength(vectorExpression)](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#vectorlength_58a039b) | Creates an expression that calculates the length of a Firestore Vector. |

## Classes

| Class | Description |
|---|---|
| [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class) | A class that represents an aggregate function. |
| [AliasedAggregate](https://firebase.google.com/docs/reference/js/firestore_pipelines.aliasedaggregate.md.txt#aliasedaggregate_class) | An AggregateFunction with alias. |
| [AliasedExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.aliasedexpression.md.txt#aliasedexpression_class) |   |
| [AliasedWindowFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aliasedwindowfunction.md.txt#aliasedwindowfunction_class) | ***(Public Preview)*** A [WindowFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.windowfunction.md.txt#windowfunction_class) with an alias.Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes |
| [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | An interface that represents a filter condition. |
| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Represents an expression that can be evaluated to a value within the execution of a [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipeline_class).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.The `Expression` class provides a fluent API for building expressions. You can chain together method calls to create complex expressions. |
| [Field](https://firebase.google.com/docs/reference/js/firestore_pipelines.field.md.txt#field_class) | Represents a reference to a field in a Firestore document, or outputs of a [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#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 [field](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.md.txt#field_1eaaff4) method: |
| [FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class) | This class defines the base class for Firestore [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#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 [and()](https://firebase.google.com/docs/reference/js/firestore.md.txt#and_e72c712), [equal()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.md.txt#equal_b3c3382), or the methods on [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) ([Expression.equal()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expressionequal), [Expression.lessThan()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expressionlessthan), etc.) to construct new Function instances. |
| [Ordering](https://firebase.google.com/docs/reference/js/firestore_pipelines.ordering.md.txt#ordering_class) | Represents an ordering criterion for sorting documents in a Firestore pipeline.You create `Ordering` instances using the `ascending` and `descending` helper functions. |
| [Pipeline](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipeline.md.txt#pipeline_class) |   |
| [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipelineresult.md.txt#pipelineresult_class) | A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the [PipelineResult.data()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresultdata) or [PipelineResult.get()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresultget) methods. If the PipelineResult represents a non-document result, `ref` will return a undefined value. |
| [PipelineSnapshot](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipelinesnapshot.md.txt#pipelinesnapshot_class) | Represents the results of a Firestore pipeline execution.A `PipelineSnapshot` contains zero or more [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) objects representing the documents returned by a pipeline query. It provides methods to iterate over the documents and access metadata about the query results. |
| [PipelineSource](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipelinesource.md.txt#pipelinesource_class) | Provides the entry point for defining the data source of a Firestore [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipeline_class).Use the methods of this class (e.g., [PipelineSource.collection()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcecollection), [PipelineSource.collectionGroup()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcecollectiongroup), [PipelineSource.database()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcedatabase), or [PipelineSource.documents()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcedocuments)) to specify the initial data for your pipeline, such as a collection, a collection group, the entire database, or a set of specific documents. |
| [WindowFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.windowfunction.md.txt#windowfunction_class) | ***(Public Preview)*** A function that is evaluated over a window frame of documents, as part of an [Pipeline.addWindowFields()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineaddwindowfields) stage.Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notesA `WindowFunction` is created either by one of the dedicated window function factories (such as [rank()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.md.txt#rank)), or by calling `over()` on an [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class). |

## Interfaces

| Interface | Description |
|---|---|
| [DocumentWindowFrame](https://firebase.google.com/docs/reference/js/firestore_pipelines.documentwindowframe.md.txt#documentwindowframe_interface) | ***(Public Preview)*** Defines a document-count based window frame relative to the position of the current document in the group.Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notesSpecifying `sort` on the enclosing [WindowSpec](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.md.txt#windowspec) is optional for `documents` window frames; if no `sort` expressions are specified, documents are processed in incoming stream (fetch) order. |
| [PipelineExecuteOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipelineexecuteoptions.md.txt#pipelineexecuteoptions_interface) | Options defining Pipeline execution. |
| [RangeWindowFrame](https://firebase.google.com/docs/reference/js/firestore_pipelines.rangewindowframe.md.txt#rangewindowframe_interface) | ***(Public Preview)*** Defines a range-value based window frame relative to the sort value(s) of the current document.Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notesOne or more `sort` expressions must be specified on the enclosing [WindowSpec](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.md.txt#windowspec) when using a `range` window frame. Range frames with numeric or time-unit offsets require a single numeric or timestamp `sort` expression, whereas frames bounded only by `'current'` and `'unbounded'` support multiple `sort` expressions and non-numeric sort values (such as strings or booleans). |
| [Selectable](https://firebase.google.com/docs/reference/js/firestore_pipelines.selectable.md.txt#selectable_interface) | An interface that represents a selectable expression. |

## Type Aliases

| Type Alias | Description |
|---|---|
| [AddFieldsStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#addfieldsstageoptions) | Options defining how an AddFieldsStage is evaluated. See [Pipeline.addFields()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineaddfields). |
| [AddWindowFieldsStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#addwindowfieldsstageoptions) | ***(Public Preview)*** Options defining how an AddWindowFieldsStage is evaluated. See [Pipeline.addWindowFields()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineaddwindowfields).Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes |
| [AggregateStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#aggregatestageoptions) | Options defining how an AggregateStage is evaluated. See [Pipeline.aggregate()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineaggregate). |
| [CollectionGroupStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#collectiongroupstageoptions) | Defines the configuration options for a CollectionGroupStage within a pipeline. This type extends [StageOptions](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.md.txt#stageoptions) and provides specific settings for how a collection group is identified and processed during pipeline execution.See [PipelineSource.collectionGroup()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcecollectiongroup) to create a collection group stage. |
| [CollectionStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#collectionstageoptions) | Options defining how a CollectionStage is evaluated. See [PipelineSource.collection()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcecollection). |
| [DatabaseStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#databasestageoptions) | Options defining how a DatabaseStage is evaluated. See [PipelineSource.database()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcedatabase). |
| [DefineStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#definestageoptions) | Options defining how a DefineStage is evaluated. See [Pipeline.define()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinedefine). |
| [DeleteStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#deletestageoptions) | Options for defining a `delete` stage in a [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipeline_class). |
| [DistinctStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#distinctstageoptions) | Options defining how a DistinctStage is evaluated. See [Pipeline.distinct()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinedistinct). |
| [DocumentsStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#documentsstageoptions) | Options defining how a DocumentsStage is evaluated. See [PipelineSource.documents()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcedocuments). |
| [ExpressionType](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#expressiontype) | An enumeration of the different types of expressions. |
| [FindNearestStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#findneareststageoptions) | Options defining how a FindNearestStage is evaluated. See [Pipeline.findNearest()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinefindnearest). |
| [InsertStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#insertstageoptions) | Options for defining an `insert` stage in a [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipeline_class).The target document path for each inserted document is determined by the combination of `collection` and `documentIdExpression`: - \*\*Neither set:\*\* Inserts each document at its existing `name` path. If an input document does not have a `name` field (for example, when inputs come from [PipelineSource.literals()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourceliterals) without `name` or after `.removeFields('name')`), the operation fails. - \*\*`collection` only:\*\* Inserts into `collection`. If the input document has a `name` field, its document ID is reused; otherwise a new document ID is auto-generated (for example, when inputs come from [PipelineSource.literals()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourceliterals) or after `.removeFields('name')`). - \*\*`documentIdExpression` only:\*\* Inserts into the input document's parent collection using the evaluated document ID. Requires each input document to have a `name` field; otherwise the operation fails. - \*\*Both `collection` and `documentIdExpression` set:\*\* Inserts into `collection` using the evaluated document ID.The operation fails if a document already exists at any target path. In particular, setting neither `collection` nor `documentIdExpression` fails for documents read from the database, because they already exist at their `name` path. |
| [LimitStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#limitstageoptions) | Options defining how a LimitStage is evaluated. See [Pipeline.limit()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinelimit). |
| [LiteralsStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#literalsstageoptions) | Options for defining a `literals` stage on a [PipelineSource](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesource_class). |
| [OffsetStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#offsetstageoptions) | Options defining how an OffsetStage is evaluated. See [Pipeline.offset()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineoffset). |
| [OneOf](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#oneof) | Utility type to create an type that only allows one property of the Type param T to be set. |
| [RemoveFieldsStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#removefieldsstageoptions) | Options defining how a RemoveFieldsStage is evaluated. See [Pipeline.removeFields()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineremovefields). |
| [ReplaceWithStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#replacewithstageoptions) | Options defining how a ReplaceWithStage is evaluated. See [Pipeline.replaceWith()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinereplacewith). |
| [SampleStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#samplestageoptions) | Defines the options for evaluating a sample stage within a pipeline. This type combines common [StageOptions](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.md.txt#stageoptions) with a specific configuration where only one of the defined sampling methods can be applied.See [Pipeline.sample()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinesample) to create a sample stage.. |
| [SearchStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#searchstageoptions) | Options defining how a search stage is evaluated. See [Pipeline.search()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinesearch). |
| [SelectStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#selectstageoptions) | Options defining how a SelectStage is evaluated. See [Pipeline.select()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineselect). |
| [SortStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#sortstageoptions) | Options defining how a SortStage is evaluated. See [Pipeline.sort()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinesort). |
| [StageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#stageoptions) | Options defining how a Stage is evaluated. |
| [SubcollectionStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#subcollectionstageoptions) | Options defining how a `SubcollectionStage` is evaluated. |
| [TimeGranularity](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timegranularity) | Specify time granularity for expressions. |
| [TimePart](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timepart) | Specify time parts for `timestampExtract` expressions. |
| [TimeUnit](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timeunit) | Specify time units for expressions. |
| [UnionStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#unionstageoptions) | Options defining how a UnionStage is evaluated. See [Pipeline.union()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineunion). |
| [UnnestStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#unneststageoptions) | Represents the specific options available for configuring an `UnnestStage` within a pipeline. |
| [UpdateStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#updatestageoptions) | Options for defining an `update` stage in a [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipeline_class).Each input document is updated in place at the path specified by its `name` field. If an input document does not have a `name` field (for example, when inputs come from [PipelineSource.literals()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourceliterals) without `name` or after `.removeFields('name')`), the operation fails.The `update` stage does not create documents. If the document at an input document's `name` path does not exist, the input document is skipped and is not counted in `documents_modified`. When the pipeline is executed with `atomic: true`, the pipeline instead fails with a `NOT_FOUND` error and no documents are updated. |
| [UpsertStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#upsertstageoptions) | Options for defining an `upsert` stage in a [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipeline_class).The target document path for each upserted document is determined by the combination of `collection` and `documentIdExpression`: - \*\*Neither set:\*\* Upserts each input document in place at its existing `name` path. If an input document does not have a `name` field (for example, when inputs come from [PipelineSource.literals()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourceliterals) without `name` or after `.removeFields('name')`), the operation fails. - \*\*`collection` only:\*\* Upserts into `collection`. If the input document has a `name` field, its document ID is reused; otherwise a new document ID is auto-generated (for example, when inputs come from [PipelineSource.literals()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourceliterals) or after `.removeFields('name')`). - \*\*Both `collection` and `documentIdExpression` set:\*\* Upserts into `collection` using the evaluated document ID.If no document exists at the target path, it is created. If one exists, it is replaced entirely by the written document; existing fields are not merged. |
| [WhereStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#wherestageoptions) | Options defining how a WhereStage is evaluated. See [Pipeline.where()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinewhere). |
| [WindowSpec](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#windowspec) | ***(Public Preview)*** A type that specifies a window frame, over which a window function will be evaluated.Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notesDefault frame behavior: - If `sort` is not specified, the default frame is `documents` from `'unbounded'` preceding to `'unbounded'` following (the entire partition/group). - If `sort` is specified, the default frame is `range` from `'unbounded'` preceding to `'current'` following (which includes all documents tied with the current document's sort value(s)). |

## function()

### countAll()

Creates an aggregation that counts the total number of stage inputs.

**Signature:**

```typescript
export declare function countAll(): AggregateFunction;
```

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'countAll' aggregation.

### Example

```typescript
// Count the total number of input documents
countAll().as("totalDocument");

```

### currentDocument()

Creates an expression that represents the current document being processed.

**Signature:**

```typescript
export declare function currentDocument(): Expression;
```

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

An [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the current document.

### Example

```typescript
// Define the current document as a variable "doc"
firestore.pipeline().collection("books")
    .define(currentDocument().as("doc"))
    // Access a field from the defined document variable
    .select(variable("doc").mapGet("title"));

```

### currentTimestamp()

Creates an expression that evaluates to the current server timestamp.

**Signature:**

```typescript
export declare function currentTimestamp(): FunctionExpression;
```

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new Expression representing the current server timestamp.

### Example

```typescript
// Get the current server timestamp
currentTimestamp()

```

### rand()

Creates an expression that generates a random number between 0.0 and 1.0 but not including 1.0.

**Signature:**

```typescript
export declare function rand(): FunctionExpression;
```

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the rand operation.

### Example

```typescript
// Generate a random number between 0.0 and 1.0.
rand();

```

### rank()

> This API is 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 rank of each document within its partition according to the window's sort order. Documents with equal sort values receive the same rank, and the following rank is skipped. The window must specify exactly one sort ordering.

Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes

**Signature:**

```typescript
export declare function rank(): WindowFunction;
```

**Returns:**

[WindowFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.windowfunction.md.txt#windowfunction_class)

A new [WindowFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.windowfunction.md.txt#windowfunction_class).

### Example

```typescript
firestore.pipeline().collection("employees")
  .addWindowFields(
    { partition: ['department'], sort: descending('salary') },
    rank().as('salaryRank')
  );

```

### score()

Evaluates to the search score that reflects the topicality of the document to all of the text predicates (for example: `documentMatches`) in the search query. If `SearchStageOptions.query` is not set or does not contain any text predicates, then this topicality score will always be `0`.

This Expression can only be used within a `search` stage.

**Signature:**

```typescript
export declare function score(): Expression;
```

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

### Example

```typescript
db.pipeline().collection('restaurants').search({
  query: 'waffles',
  sort: score().descending()
})

```

## function(array, ...)

### arrayContains(array, element)

Creates an expression that checks if an array expression contains a specific element.

**Signature:**

```typescript
export declare function arrayContains(
  array: Expression,
  element: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| array | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The array expression to check. |
| element | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The element to search for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains' comparison.

### Example

```typescript
// Check if the 'colors' array contains the value of field 'selectedColor'
arrayContains(field("colors"), field("selectedColor"));

```

### arrayContains(array, element)

Creates an expression that checks if an array expression contains a specific element.

**Signature:**

```typescript
export declare function arrayContains(
  array: Expression,
  element: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| array | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The array expression to check. |
| element | unknown | The element to search for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains' comparison.

### Example

```typescript
// Check if the 'colors' array contains "red"
arrayContains(field("colors"), "red");

```

### arrayContainsAll(array, values)

Creates an expression that checks if an array expression contains all the specified elements.

**Signature:**

```typescript
export declare function arrayContainsAll(
  array: Expression,
  values: Array<Expression | unknown>
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| array | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The array expression to check. |
| values | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | The elements to check for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains_all' comparison.

### Example

```typescript
// 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"]);

```

### arrayContainsAll(array, arrayExpression)

Creates an expression that checks if an array expression contains all the specified elements.

**Signature:**

```typescript
export declare function arrayContainsAll(
  array: Expression,
  arrayExpression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| array | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The array expression to check. |
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The elements to check for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains_all' comparison.

### Example

```typescript
// 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"]);

```

### arrayContainsAny(array, values)

Creates an expression that checks if an array expression contains any of the specified elements.

**Signature:**

```typescript
export declare function arrayContainsAny(
  array: Expression,
  values: Array<Expression | unknown>
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| array | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The array expression to check. |
| values | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | The elements to check for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains_any' comparison.

### Example

```typescript
// Check if the 'categories' array contains either values from field "cate1" or "Science"
arrayContainsAny(field("categories"), [field("cate1"), "Science"]);

```

### arrayContainsAny(array, values)

Creates an expression that checks if an array expression contains any of the specified elements.

**Signature:**

```typescript
export declare function arrayContainsAny(
  array: Expression,
  values: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| array | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The array expression to check. |
| values | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that evaluates to an array, whose elements to check for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains_any' comparison.

### Example

```typescript
// Check if the 'categories' array contains either values from field "cate1" or "Science"
arrayContainsAny(field("categories"), array([field("cate1"), "Science"]));

```

### arrayLength(array)

Creates an expression that calculates the length of an array expression.

**Signature:**

```typescript
export declare function arrayLength(array: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| array | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The array expression to calculate the length of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the length of the array.

### Example

```typescript
// Get the number of items in the 'cart' array
arrayLength(field("cart"));

```

## function(arrayExpression, ...)

### arrayFilter(arrayExpression, alias, filter)

Creates an expression that filters an array using a provided alias and predicate expression.

**Signature:**

```typescript
export declare function arrayFilter(
  arrayExpression: Expression,
  alias: string,
  filter: BooleanExpression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| alias | string | The variable name to use for each element. |
| filter | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The predicate boolean expression to filter by. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the filtered array.

### Example

```typescript
// Filter "scores" to include only values greater than 50
arrayFilter(field("scores"), "score", greaterThan(variable("score"), 50));

```

### arrayFirst(arrayExpression)

Creates an expression that returns the first element of an array.

**Signature:**

```typescript
export declare function arrayFirst(
  arrayExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the first element.

### Example

```typescript
// Get the first tag from the 'tags' array field
arrayFirst(field("tags"));

```

### arrayFirstN(arrayExpression, n)

Creates an expression that returns the first `n` elements of an array.

**Signature:**

```typescript
export declare function arrayFirstN(
  arrayExpression: Expression,
  n: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| n | number | The number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the first `n` elements.

### Example

```typescript
// Get the first 3 elements from an array expression
arrayFirstN(field("tags"), 3);

```

### arrayFirstN(arrayExpression, n)

Creates an expression that returns the first `n` elements of an array.

**Signature:**

```typescript
export declare function arrayFirstN(
  arrayExpression: Expression,
  n: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| n | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to the number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the first `n` elements.

### Example

```typescript
// Get the first n elements from an array expression
arrayFirstN(field("tags"), field("count"));

```

### arrayGet(arrayExpression, offset)

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.

**Signature:**

```typescript
export declare function arrayGet(
  arrayExpression: Expression,
  offset: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An `Expression` evaluating to an array. |
| offset | number | The index of the element to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the 'arrayGet' operation.

### Example

```typescript
// Return the value in the tags field array at index 1.
arrayGet(field('tags'), 1);

```

### arrayGet(arrayExpression, offsetExpr)

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.

**Signature:**

```typescript
export declare function arrayGet(
  arrayExpression: Expression,
  offsetExpr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An `Expression` evaluating to an array. |
| offsetExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An `Expression` evaluating to the index of the element to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the 'arrayGet' operation.

### Example

```typescript
// Return the value in the tags field array at index specified by field
// 'favoriteTag'.
arrayGet(field('tags'), field('favoriteTag'));

```

### arrayIndexOf(arrayExpression, search)

Creates an expression that returns the first index of the search value in an array. Returns -1 if the value is not found.

**Signature:**

```typescript
export declare function arrayIndexOf(
  arrayExpression: Expression,
  search: unknown | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array to search. |
| search | unknown \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The value to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the index.

### Example

```typescript
// Get the index of "politics" in the 'tags' array field
arrayIndexOf(field("tags"), "politics");

```

### arrayIndexOfAll(arrayExpression, search)

Creates an expression that returns all indices of the search value in an array.

**Signature:**

```typescript
export declare function arrayIndexOfAll(
  arrayExpression: Expression,
  search: unknown | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array to search. |
| search | unknown \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The value to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the indices.

### Example

```typescript
// Get all indices of 5 in the 'scores' array field
arrayIndexOfAll(field("scores"), 5);

```

### arrayLast(arrayExpression)

Creates an expression that returns the last element of an array.

**Signature:**

```typescript
export declare function arrayLast(
  arrayExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the last element.

### Example

```typescript
// Get the last tag from the 'tags' array field
arrayLast(field("tags"));

```

### arrayLastIndexOf(arrayExpression, search)

Creates an expression that returns the last index of the search value in an array. Returns -1 if the value is not found.

**Signature:**

```typescript
export declare function arrayLastIndexOf(
  arrayExpression: Expression,
  search: unknown | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array to search. |
| search | unknown \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The value to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the index.

### Example

```typescript
// Get the last index of "politics" in the 'tags' array field
arrayLastIndexOf(field("tags"), "politics");

```

### arrayLastN(arrayExpression, n)

Creates an expression that returns the last `n` elements of an array.

**Signature:**

```typescript
export declare function arrayLastN(
  arrayExpression: Expression,
  n: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| n | number | The number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the last `n` elements.

### Example

```typescript
// Get the last 3 elements from an array expression
arrayLastN(field("tags"), 3);

```

### arrayLastN(arrayExpression, n)

Creates an expression that returns the last `n` elements of an array.

**Signature:**

```typescript
export declare function arrayLastN(
  arrayExpression: Expression,
  n: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| n | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to the number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the last `n` elements.

### Example

```typescript
// Get the last n elements from an array expression
arrayLastN(field("tags"), field("count"));

```

### arrayMaximum(arrayExpression)

Creates an expression that returns the maximum value in an array.

**Signature:**

```typescript
export declare function arrayMaximum(
  arrayExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the maximum value.

### Example

```typescript
// Get the maximum value from the 'scores' array field
arrayMaximum(field("scores"));

```

### arrayMaximumN(arrayExpression, n)

Creates an expression that returns the largest `n` elements of an array.

> [!NOTE]
> **Note:** Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.

**Signature:**

```typescript
export declare function arrayMaximumN(
  arrayExpression: Expression,
  n: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| n | number | The number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the largest `n` elements.

### Example

```typescript
// Get the top 3 elements from an array expression
arrayMaximumN(field("scores"), 3);

```

### arrayMaximumN(arrayExpression, n)

Creates an expression that returns the largest `n` elements of an array.

> [!NOTE]
> **Note:** Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.

**Signature:**

```typescript
export declare function arrayMaximumN(
  arrayExpression: Expression,
  n: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| n | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to the number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the largest `n` elements.

### Example

```typescript
// Get the top n elements from an array expression
arrayMaximumN(field("scores"), field("count"));

```

### arrayMinimum(arrayExpression)

Creates an expression that returns the minimum value in an array.

**Signature:**

```typescript
export declare function arrayMinimum(
  arrayExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the minimum value.

### Example

```typescript
// Get the minimum value from the 'scores' array field
arrayMinimum(field("scores"));

```

### arrayMinimumN(arrayExpression, n)

Creates an expression that returns the smallest `n` elements of an array.

> [!NOTE]
> **Note:** Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.

**Signature:**

```typescript
export declare function arrayMinimumN(
  arrayExpression: Expression,
  n: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| n | number | The number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the smallest `n` elements.

### Example

```typescript
// Get the bottom 3 scores from the 'scores' array field
arrayMinimumN(field("scores"), 3);

```

### arrayMinimumN(arrayExpression, n)

Creates an expression that returns the smallest `n` elements of an array.

> [!NOTE]
> **Note:** Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.

**Signature:**

```typescript
export declare function arrayMinimumN(
  arrayExpression: Expression,
  n: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| n | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to the number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the smallest `n` elements.

### Example

```typescript
// Get the bottom n scores from the 'scores' array field
arrayMinimumN(field("scores"), field("count"));

```

### arraySlice(arrayExpression, offset, length)

Creates an expression that returns a slice of an array from `offset` with `length` elements.

**Signature:**

```typescript
export declare function arraySlice(
  arrayExpression: Expression,
  offset: number | Expression,
  length?: number | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| offset | number \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The starting offset. |
| length | number \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The optional length of the slice. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the sliced array.

### Example

```typescript
// Get 5 elements from an array expression starting from index 2
arraySlice(field("items"), 2, 5);

// Get n elements from an array expression starting from index 2
arraySlice(field("items"), 2, field("length"));

```

### arrayTransform(arrayExpression, elementAlias, transform)

Creates an expression that applies a provided transformation to each element in an array.

**Signature:**

```typescript
export declare function arrayTransform(
  arrayExpression: Expression,
  elementAlias: string,
  transform: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| elementAlias | string | The variable name to use for each element. |
| transform | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The lambda expression used to transform the elements. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the transformed array.

### Example

```typescript
// Transform "scores" array by multiplying each score by 10
arrayTransform(field("scores"), "score", multiply(variable("score"), 10));

```

### arrayTransformWithIndex(arrayExpression, elementAlias, indexAlias, transform)

Creates an expression that applies a provided transformation to each element in an array, providing the element's index to the transformation expression.

**Signature:**

```typescript
export declare function arrayTransformWithIndex(
  arrayExpression: Expression,
  elementAlias: string,
  indexAlias: string,
  transform: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the array. |
| elementAlias | string | The variable name to use for each element. |
| indexAlias | string | The variable name to use for the current index. |
| transform | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression used to transform the elements. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the transformed array.

### Example

```typescript
// Transform "scores" array by adding the index to each score
arrayTransformWithIndex(field("scores"), "score", "i", add(variable("score"), variable("i")));

```

### join(arrayExpression, delimiterExpression)

Creates an expression that joins the elements of an array into a string.

**Signature:**

```typescript
export declare function join(
  arrayExpression: Expression,
  delimiterExpression: Expression
): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that evaluates to an array. |
| delimiterExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression that evaluates to the delimiter string. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new Expression representing the join operation.

### Example

```typescript
// Join an array of string using the delimiter from the 'separator' field.
join(array(['foo', 'bar']), field("separator"))

```

### join(arrayExpression, delimiter)

Creates an expression that joins the elements of an array into a string.

**Signature:**

```typescript
export declare function join(
  arrayExpression: Expression,
  delimiter: string
): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that evaluates to an array. |
| delimiter | string | The string to use as a delimiter. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new Expression representing the join operation.

### Example

```typescript
// Join the elements of the 'tags' field with a comma and space.
join(field("tags"), ", ")

```

## function(arrayField, ...)

### arrayGet(arrayField, offset)

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.

**Signature:**

```typescript
export declare function arrayGet(
  arrayField: string,
  offset: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayField | string | The name of the array field. |
| offset | number | The index of the element to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the 'arrayGet' operation.

### Example

```typescript
// Return the value in the tags field array at index 1.
arrayGet('tags', 1);

```

### arrayGet(arrayField, offsetExpr)

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.

**Signature:**

```typescript
export declare function arrayGet(
  arrayField: string,
  offsetExpr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayField | string | The name of the array field. |
| offsetExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An `Expression` evaluating to the index of the element to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the 'arrayGet' operation.

### Example

```typescript
// Return the value in the tags field array at index specified by field
// 'favoriteTag'.
arrayGet('tags', field('favoriteTag'));

```

## function(arrayFieldName, ...)

### join(arrayFieldName, delimiter)

Creates an expression that joins the elements of an array into a string.

**Signature:**

```typescript
export declare function join(
  arrayFieldName: string,
  delimiter: string
): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayFieldName | string | The name of the field containing the array. |
| delimiter | string | The string to use as a delimiter. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new Expression representing the join operation.

### Example

```typescript
// Join the elements of the 'tags' field with a comma and space.
join("tags", ", ")

```

### join(arrayFieldName, delimiterExpression)

Creates an expression that joins the elements of an array into a string.

**Signature:**

```typescript
export declare function join(
  arrayFieldName: string,
  delimiterExpression: Expression
): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| arrayFieldName | string | The name of the field containing the array. |
| delimiterExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression that evaluates to the delimiter string. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new Expression representing the join operation.

### Example

```typescript
// Join the elements of the 'tags' field with the delimiter from the 'separator' field.
join('tags', field("separator"))

```

## function(base, ...)

### pow(base, exponent)

Creates an expression that returns the value of the base expression raised to the power of the exponent expression.

**Signature:**

```typescript
export declare function pow(
  base: Expression,
  exponent: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| base | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to raise to the power of the exponent. |
| exponent | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to raise the base to the power of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the power operation.

### Example

```typescript
// Raise the value of the 'base' field to the power of the 'exponent' field.
pow(field("base"), field("exponent"));

```

### pow(base, exponent)

Creates an expression that returns the value of the base expression raised to the power of the exponent.

**Signature:**

```typescript
export declare function pow(
  base: Expression,
  exponent: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| base | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to raise to the power of the exponent. |
| exponent | number | The constant value to raise the base to the power of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the power operation.

### Example

```typescript
// Raise the value of the 'base' field to the power of 2.
pow(field("base"), 2);

```

### pow(base, exponent)

Creates an expression that returns the value of the base field raised to the power of the exponent expression.

**Signature:**

```typescript
export declare function pow(
  base: string,
  exponent: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| base | string | The name of the field to raise to the power of the exponent. |
| exponent | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to raise the base to the power of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the power operation.

### Example

```typescript
// Raise the value of the 'base' field to the power of the 'exponent' field.
pow("base", field("exponent"));

```

### pow(base, exponent)

Creates an expression that returns the value of the base field raised to the power of the exponent.

**Signature:**

```typescript
export declare function pow(base: string, exponent: number): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| base | string | The name of the field to raise to the power of the exponent. |
| exponent | number | The constant value to raise the base to the power of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the power operation.

### Example

```typescript
// Raise the value of the 'base' field to the power of 2.
pow("base", 2);

```

## function(booleanExpr, ...)

### countIf(booleanExpr)

Creates an aggregation that counts the number of stage inputs where the provided boolean expression evaluates to true.

**Signature:**

```typescript
export declare function countIf(
  booleanExpr: BooleanExpression
): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| booleanExpr | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The boolean expression to evaluate on each input. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new `AggregateFunction` representing the 'countIf' aggregation.

### Example

```typescript
// Count the number of documents where 'is_active' field equals true
countIf(field("is_active").equal(true)).as("numActiveDocuments");

```

### not(booleanExpr)

Creates an expression that negates a filter condition.

**Signature:**

```typescript
export declare function not(booleanExpr: BooleanExpression): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| booleanExpr | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The filter condition to negate. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the negated filter condition.

### Example

```typescript
// Find documents where the 'completed' field is NOT true
not(equal("completed", true));

```

## function(condition, ...)

### conditional(condition, thenExpr, elseExpr)

Creates a conditional expression that evaluates to a 'then' expression if a condition is true and an 'else' expression if the condition is false.

**Signature:**

```typescript
export declare function conditional(
  condition: BooleanExpression,
  thenExpr: Expression,
  elseExpr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| condition | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The condition to evaluate. |
| thenExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to evaluate if the condition is true. |
| elseExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to evaluate if the condition is false. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the conditional expression.

### Example

```typescript
// If 'age' is greater than 18, return "Adult"; otherwise, return "Minor".
conditional(
    greaterThan("age", 18), constant("Adult"), constant("Minor"));

```

### switchOn(condition, result, others)

Creates an expression that evaluates to the result corresponding to the first true condition.

This function behaves like a `switch` statement. It accepts an alternating sequence of conditions and their corresponding results. If an odd number of arguments is provided, the final argument serves as a default fallback result. If no default is provided and no condition evaluates to true, it throws an error.

**Signature:**

```typescript
export declare function switchOn(
  condition: BooleanExpression,
  result: Expression,
  ...others: Array<BooleanExpression | Expression>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| condition | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The first condition to check. |
| result | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The result if the first condition is true. |
| others | Array\<[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)\> | Additional conditions and results, and optionally a default value. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new Expression representing the switch operation.

### Example

```typescript
// Return "Active" if field "status" is 1, "Pending" if field "status" is 2,
// and default to "Unknown" if none of the conditions are true.
switchOn(
  equal(field("status"), 1), constant("Active"),
  equal(field("status"), 2), constant("Pending"),
  constant("Unknown")
)

```

## function(documentPath, ...)

### documentId(documentPath)

Creates an expression that returns the document ID from a path.

**Signature:**

```typescript
export declare function documentId(
  documentPath: string | DocumentReference
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| documentPath | string \| [DocumentReference](https://firebase.google.com/docs/reference/js/firestore.documentreference.md.txt#documentreference_class) |   |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the documentId operation.

### Example

```typescript
// Get the document ID from a path.
documentId(myDocumentReference);

```

### parent_2(documentPath)

Creates an expression that returns the parent document reference of a document reference.

**Signature:**

```typescript
declare function parent_2(
  documentPath: string | DocumentReference
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| documentPath | string \| [DocumentReference](https://firebase.google.com/docs/reference/js/firestore.documentreference.md.txt#documentreference_class) | A string path or DocumentReference to get the parent from. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the parent operation.

### Example

```typescript
// Get the parent document reference of a document reference.
parent(myDocumentReference);

```

## function(documentPathExpr, ...)

### documentId(documentPathExpr)

Creates an expression that returns the document ID from a path.

**Signature:**

```typescript
export declare function documentId(
  documentPathExpr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| documentPathExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) |   |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the documentId operation.

### Example

```typescript
// Get the document ID from a path.
documentId(field("__path__"));

```

### parent_2(documentPathExpr)

Creates an expression that returns the parent document reference of a document reference.

**Signature:**

```typescript
declare function parent_2(documentPathExpr: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| documentPathExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An Expression evaluating to a document reference. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the parent operation.

### Example

```typescript
// Get the parent document reference of a document reference.
parent(field("__path__"));

```

## function(element, ...)

### notEqualAny(element, values)

Creates an expression that checks if an expression is not equal to any of the provided values or expressions.

**Signature:**

```typescript
export declare function notEqualAny(
  element: Expression,
  values: Array<Expression | unknown>
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| element | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare. |
| values | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | The values to check against. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'NOT IN' comparison.

### Example

```typescript
// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus'
notEqualAny(field("status"), ["pending", field("rejectedStatus")]);

```

### notEqualAny(element, arrayExpression)

Creates an expression that checks if an expression is not equal to any of the provided values or expressions.

**Signature:**

```typescript
export declare function notEqualAny(
  element: Expression,
  arrayExpression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| element | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare. |
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The values to check against. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'NOT IN' comparison.

### Example

```typescript
// Check if the 'status' field is neither "pending" nor the value of the field 'rejectedStatus'
notEqualAny(field("status"), ["pending", field("rejectedStatus")]);

```

## function(elements, ...)

### array(elements)

Creates an expression that creates a Firestore array value from an input array.

**Signature:**

```typescript
export declare function array(elements: unknown[]): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| elements | unknown\[\] | The input array to evaluate in the expression. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the array function.

### Example

```typescript
// Create an array value from the input array and reference the 'baz' field value from the input document.
array(['bar', field('baz')]).as('foo');

```

### map(elements)

Creates an expression that creates a Firestore map value from an input object.

**Signature:**

```typescript
export declare function map(
  elements: Record<string, unknown>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| elements | Record\<string, unknown\> | The input map to evaluate in the expression. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the map function.

### Example

```typescript
// Create a map from the input object and reference the 'baz' field value from the input document.
map({foo: 'bar', baz: field('baz')}).as('data');

```

## function(endExpression, ...)

### timestampDiff(endExpression, startFieldName, unit)

Creates an expression that calculates the difference between two timestamps.

**Signature:**

```typescript
export declare function timestampDiff(
  endExpression: Expression,
  startFieldName: string,
  unit: TimeUnit | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| endExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The ending timestamp for the difference calculation. |
| startFieldName | string | The name of the field representing the starting timestamp. |
| unit | [TimeUnit](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timeunit) \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The unit of time for the difference (e.g., "day", "hour"). |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the difference as an integer.

### Example

```typescript
// Calculate the difference in days between an ending timestamp expression and 'startTime' field.
timestampDiff(field('endTime'), 'startTime', 'day')

```

### timestampDiff(endExpression, startExpression, unit)

Creates an expression that calculates the difference between two timestamps.

**Signature:**

```typescript
export declare function timestampDiff(
  endExpression: Expression,
  startExpression: Expression,
  unit: TimeUnit | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| endExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The ending timestamp for the difference calculation. |
| startExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The starting timestamp for the difference calculation. |
| unit | [TimeUnit](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timeunit) \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The unit of time for the difference (e.g., "day", "hour"). |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the difference as an integer.

### Example

```typescript
// Calculate the difference in days between two timestamp expressions.
timestampDiff(field('endTime'), field('startTime'), 'day')

```

## function(endFieldName, ...)

### timestampDiff(endFieldName, startFieldName, unit)

**Signature:**

```typescript
export declare function timestampDiff(
  endFieldName: string,
  startFieldName: string,
  unit: TimeUnit | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| endFieldName | string |   |
| startFieldName | string |   |
| unit | [TimeUnit](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timeunit) \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) |   |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

### timestampDiff(endFieldName, startExpression, unit)

Creates an expression that calculates the difference between two timestamps.

**Signature:**

```typescript
export declare function timestampDiff(
  endFieldName: string,
  startExpression: Expression,
  unit: TimeUnit | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| endFieldName | string | The name of the field representing the ending timestamp. |
| startExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The starting timestamp for the difference calculation. |
| unit | [TimeUnit](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timeunit) \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The unit of time for the difference (e.g., "day", "hour"). |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the difference as an integer.

### Example

```typescript
// Calculate the difference in days between 'endTime' field and a starting timestamp expression.
timestampDiff('endTime', field('startTime'), 'day')

```

## function(expr, ...)

### abs(expr)

Creates an expression that computes the absolute value of a numeric value.

**Signature:**

```typescript
export declare function abs(expr: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compute the absolute value of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the absolute value of the numeric value.

### ascending(expr)

Creates an [Ordering](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.ordering.md.txt#ordering_class) that sorts documents in ascending order based on an expression.

**Signature:**

```typescript
export declare function ascending(expr: Expression): Ordering;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to create an ascending ordering for. |

**Returns:**

[Ordering](https://firebase.google.com/docs/reference/js/firestore_pipelines.ordering.md.txt#ordering_class)

A new `Ordering` for ascending sorting.

### Example

```typescript
// Sort documents by the 'name' field in lowercase in ascending order
firestore.pipeline().collection("users")
  .sort(ascending(field("name").toLower()));

```

### byteLength(expr)

Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob.

**Signature:**

```typescript
export declare function byteLength(expr: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the length of the string in bytes.

### Example

```typescript
// Calculate the length of the 'myString' field in bytes.
byteLength(field("myString"));

```

### countDistinct(expr)

Creates an aggregation that counts the number of distinct values of a field.

**Signature:**

```typescript
export declare function countDistinct(
  expr: Expression | string
): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| string | The expression or field to count distinct values of. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new `AggregateFunction` representing the 'count_distinct' aggregation.

### descending(expr)

Creates an [Ordering](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.ordering.md.txt#ordering_class) that sorts documents in descending order based on an expression.

**Signature:**

```typescript
export declare function descending(expr: Expression): Ordering;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to create a descending ordering for. |

**Returns:**

[Ordering](https://firebase.google.com/docs/reference/js/firestore_pipelines.ordering.md.txt#ordering_class)

A new `Ordering` for descending sorting.

### Example

```typescript
// Sort documents by the 'name' field in lowercase in descending order
firestore.pipeline().collection("users")
  .sort(descending(field("name").toLower()));

```

### floor(expr)

Creates an expression that computes the floor of a numeric value.

**Signature:**

```typescript
export declare function floor(expr: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compute the floor of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the floor of the numeric value.

### timestampToUnixMicros(expr)

Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

**Signature:**

```typescript
export declare function timestampToUnixMicros(
  expr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the timestamp. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the number of microseconds since epoch.

### Example

```typescript
// Convert the 'timestamp' field to microseconds since epoch.
timestampToUnixMicros(field("timestamp"));

```

### timestampToUnixMillis(expr)

Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

**Signature:**

```typescript
export declare function timestampToUnixMillis(
  expr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the timestamp. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the number of milliseconds since epoch.

### Example

```typescript
// Convert the 'timestamp' field to milliseconds since epoch.
timestampToUnixMillis(field("timestamp"));

```

### timestampToUnixSeconds(expr)

Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).

**Signature:**

```typescript
export declare function timestampToUnixSeconds(
  expr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the timestamp. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the number of seconds since epoch.

### Example

```typescript
// Convert the 'timestamp' field to seconds since epoch.
timestampToUnixSeconds(field("timestamp"));

```

### unixMicrosToTimestamp(expr)

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.

**Signature:**

```typescript
export declare function unixMicrosToTimestamp(
  expr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the number of microseconds since epoch. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the timestamp.

### Example

```typescript
// Interpret the 'microseconds' field as microseconds since epoch.
unixMicrosToTimestamp(field("microseconds"));

```

### unixMillisToTimestamp(expr)

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.

**Signature:**

```typescript
export declare function unixMillisToTimestamp(
  expr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the number of milliseconds since epoch. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the timestamp.

### Example

```typescript
// Interpret the 'milliseconds' field as milliseconds since epoch.
unixMillisToTimestamp(field("milliseconds"));

```

### unixSecondsToTimestamp(expr)

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.

**Signature:**

```typescript
export declare function unixSecondsToTimestamp(
  expr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the number of seconds since epoch. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the timestamp.

### Example

```typescript
// Interpret the 'seconds' field as seconds since epoch.
unixSecondsToTimestamp(field("seconds"));

```

## function(expression, ...)

### arrayAgg(expression)

Creates an aggregation that collects all values of an expression across multiple stage inputs into an array.

If the expression resolves to an absent value, it is converted to `null`. The order of elements in the output array is not stable and shouldn't be relied upon.

**Signature:**

```typescript
export declare function arrayAgg(expression: Expression): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to collect values from. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'array_agg' aggregation.

### Example

```typescript
// Collect all tags from books into an array
arrayAgg(field("tags")).as("allTags");

```

### arrayAggDistinct(expression)

Creates an aggregation that collects all distinct values of an expression across multiple stage inputs into an array.

If the expression resolves to an absent value, it is converted to `null`. The order of elements in the output array is not stable and shouldn't be relied upon.

**Signature:**

```typescript
export declare function arrayAggDistinct(
  expression: Expression
): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to collect values from. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'array_agg_distinct' aggregation.

### Example

```typescript
// Collect all distinct tags from books into an array
arrayAggDistinct(field("tags")).as("allDistinctTags");

```

### arraySum(expression)

Creates an expression that computes the sum of the elements in an array.

**Signature:**

```typescript
export declare function arraySum(expression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric array, which the sum will be computed for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the sum of the elements in the array.

### Example

```typescript
// Compute the sum of the elements in the 'scores' field.
arraySum(field("scores"));

```

### average(expression)

Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs.

**Signature:**

```typescript
export declare function average(expression: Expression): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the values to average. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'average' aggregation.

### Example

```typescript
// Calculate the average age of users
average(field("age")).as("averageAge");

```

### ceil(expression)

Creates an expression that computes the ceiling of a numeric value.

**Signature:**

```typescript
export declare function ceil(expression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric value, which the ceiling will be computed for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the ceiling of the numeric value.

### Example

```typescript
// Compute the ceiling of the 'price' field.
ceil(field("price"));

```

### coalesce(expression, replacement, others)

Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument.

**Signature:**

```typescript
export declare function coalesce(
  expression: Expression,
  replacement: Expression | unknown,
  ...others: Array<Expression | unknown>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first expression to check for null. |
| replacement | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The fallback expression or value if the first one is null. |
| others | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | Optional additional expressions to check if previous ones are null. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the coalesce operation.

### Example

```typescript
// Returns the value of the first non-null, non-absent field among 'preferredName', 'fullName',
// or the last argument if all previous fields are null.
coalesce(field("preferredName"), field("fullName"), constant("Anonymous"))

```

### collectionId(expression)

Creates an expression that returns the collection ID from a path.

**Signature:**

```typescript
export declare function collectionId(
  expression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a path, which the collection ID will be extracted from. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the collectionId operation.

### Example

```typescript
// Get the collection ID from a path.
collectionId(field("__name__"));

```

### count(expression)

Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided expression.

**Signature:**

```typescript
export declare function count(expression: Expression): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to count. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'count' aggregation.

### Example

```typescript
// Count the number of items where the price is greater than 10
count(field("price").greaterThan(10)).as("expensiveItemCount");

```

### divide(expression, value)

Creates an expression that divides an expression by a constant value.

**Signature:**

```typescript
export declare function divide(
  expression: Expression,
  value: unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to be divided. |
| value | unknown | The constant value to divide by. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the division operation.

### Example

```typescript
// Divide the 'value' field by 10
divide(field("value"), 10);

```

### equal(expression, value)

Creates an expression that checks if an expression is equal to a constant value.

**Signature:**

```typescript
export declare function equal(
  expression: Expression,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the equality comparison.

### Example

```typescript
// Check if the 'age' field is equal to 21
equal(field("age"), 21);

```

### equalAny(expression, values)

Creates an expression that checks if an expression, when evaluated, is equal to any of the provided values or expressions.

**Signature:**

```typescript
export declare function equalAny(
  expression: Expression,
  values: Array<Expression | unknown>
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression whose results to compare. |
| values | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | The values to check against. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'IN' comparison.

### Example

```typescript
// Check if the 'category' field is either "Electronics" or value of field 'primaryType'
equalAny(field("category"), [constant("Electronics"), field("primaryType")]);

```

### equalAny(expression, arrayExpression)

Creates an expression that checks if an expression is equal to any of the provided values.

**Signature:**

```typescript
export declare function equalAny(
  expression: Expression,
  arrayExpression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression whose results to compare. |
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that evaluates to an array, whose elements to check for equality to the input. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'IN' comparison.

### Example

```typescript
// Check if the 'category' field is set to a value in the disabledCategories field
equalAny(field("category"), field('disabledCategories'));

```

### exp(expression)

Creates an expression that computes e to the power of the expression's result.

**Signature:**

```typescript
export declare function exp(expression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) |   |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the exp of the numeric value.

### Example

```typescript
// Compute e to the power of 2.
exp(constant(2));

```

### first(expression)

Creates an aggregation that finds the first value of an expression across multiple stage inputs.

**Signature:**

```typescript
export declare function first(expression: Expression): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to find the first value of. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'first' aggregation.

### Example

```typescript
// Find the first value of the 'rating' field
first(field("rating")).as("firstRating");

```

### greaterThan(expression, value)

Creates an expression that checks if an expression is greater than a constant value.

**Signature:**

```typescript
export declare function greaterThan(
  expression: Expression,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the greater than comparison.

### Example

```typescript
// Check if the 'age' field is greater than 18
greaterThan(field("age"), 18);

```

### greaterThanOrEqual(expression, value)

Creates an expression that checks if an expression is greater than or equal to a constant value.

**Signature:**

```typescript
export declare function greaterThanOrEqual(
  expression: Expression,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the greater than or equal to comparison.

### Example

```typescript
// Check if the 'quantity' field is greater than or equal to 10
greaterThanOrEqual(field("quantity"), 10);

```

### isType(expression, type)

Creates an expression that checks if the result of an expression is of the given type.

Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data. Supported values for `type` are: `'null'`, `'array'`, `'boolean'`, `'bytes'`, `'timestamp'`, `'geo_point'`, `'number'`, `'int32'`, `'int64'`, `'float64'`, `'decimal128'`, `'map'`, `'reference'`, `'string'`, `'vector'`, `'max_key'`, `'min_key'`, `'object_id'`, `'regex'`, `'request_timestamp'`.

**Signature:**

```typescript
export declare function isType(
  expression: Expression,
  type: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check. |
| type | string | The type to check for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `BooleanExpression` that evaluates to true if the expression's result is of the given type, false otherwise.

### Example

```typescript
// Check if the result of a calculation is a number
isType(add('count', 1), 'number')

```

### last(expression)

Creates an aggregation that finds the last value of an expression across multiple stage inputs.

**Signature:**

```typescript
export declare function last(expression: Expression): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to find the last value of. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'last' aggregation.

### Example

```typescript
// Find the last value of the 'rating' field
last(field("rating")).as("lastRating");

```

### length_2(expression)

Creates an expression that calculates the length of a string, array, map, vector, or bytes.

**Signature:**

```typescript
declare function length_2(expression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a string, array, map, vector, or bytes, which the length will be calculated for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the length of the string, array, map, vector, or bytes.

### Example

```typescript
// Get the length of the 'name' field.
length(field("name"));

// Get the number of items in the 'cart' array.
length(field("cart"));

```

### lessThan(expression, value)

Creates an expression that checks if an expression is less than a constant value.

**Signature:**

```typescript
export declare function lessThan(
  expression: Expression,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the less than comparison.

### Example

```typescript
// Check if the 'age' field is less than 30
lessThan(field("age"), 30);

```

### lessThanOrEqual(expression, value)

Creates an expression that checks if an expression is less than or equal to a constant value.

**Signature:**

```typescript
export declare function lessThanOrEqual(
  expression: Expression,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the less than or equal to comparison.

### Example

```typescript
// Check if the 'quantity' field is less than or equal to 20
lessThan(field("quantity"), 20);

```

### ln(expression)

Creates an expression that computes the natural logarithm of a numeric value.

**Signature:**

```typescript
export declare function ln(expression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric value, which the natural logarithm will be computed for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the natural logarithm of the numeric value.

### Example

```typescript
// Compute the natural logarithm of the 'value' field.
ln(field("value"));

```

### log(expression, base)

Creates an expression that computes the logarithm of an expression to a given base.

**Signature:**

```typescript
export declare function log(
  expression: Expression,
  base: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric value, which the logarithm will be computed for. |
| base | number | The base of the logarithm. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logarithm of the numeric value.

### Example

```typescript
// Compute the logarithm of the 'value' field with base 10.
log(field("value"), 10);

```

### log(expression, base)

Creates an expression that computes the logarithm of an expression to a given base.

**Signature:**

```typescript
export declare function log(
  expression: Expression,
  base: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric value, which the logarithm will be computed for. |
| base | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The base of the logarithm. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logarithm of the numeric value.

### Example

```typescript
// Compute the logarithm of the 'value' field with the base in the 'base' field.
log(field("value"), field("base"));

```

### log10(expression)

Creates an expression that computes the base-10 logarithm of a numeric value.

**Signature:**

```typescript
export declare function log10(expression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric value, which the base-10 logarithm will be computed for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the base-10 logarithm of the numeric value.

### Example

```typescript
// Compute the base-10 logarithm of the 'value' field.
log10(field("value"));

```

### ltrim(expression, valueToTrim)

Trims whitespace or a specified set of characters/bytes from the beginning of a string or byte array.

**Signature:**

```typescript
export declare function ltrim(
  expression: Expression,
  valueToTrim?: string | Expression | Bytes
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string or byte array. |
| valueToTrim | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | Optional. A string or byte array containing the characters/bytes to trim. If not specified, whitespace will be trimmed. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the trimmed string or byte array.

### Example

```typescript
// Trim whitespace from the beginning of the 'userInput' field
ltrim(field("userInput"));

// Trim quotes from the beginning of the 'userInput' field
ltrim(field("userInput"), '"');

```

### maximum(expression)

Creates an aggregation that finds the maximum value of an expression across multiple stage inputs.

**Signature:**

```typescript
export declare function maximum(expression: Expression): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to find the maximum value of. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'maximum' aggregation.

### Example

```typescript
// Find the highest score in a leaderboard
maximum(field("score")).as("highestScore");

```

### minimum(expression)

Creates an aggregation that finds the minimum value of an expression across multiple stage inputs.

**Signature:**

```typescript
export declare function minimum(expression: Expression): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to find the minimum value of. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'minimum' aggregation.

### Example

```typescript
// Find the lowest price of all products
minimum(field("price")).as("lowestPrice");

```

### mod(expression, value)

Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant.

**Signature:**

```typescript
export declare function mod(
  expression: Expression,
  value: unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The dividend expression. |
| value | unknown | The divisor constant. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the modulo operation.

### Example

```typescript
// Calculate the remainder of dividing 'field1' by 5.
mod(field("field1"), 5);

```

### notEqual(expression, value)

Creates an expression that checks if an expression is not equal to a constant value.

**Signature:**

```typescript
export declare function notEqual(
  expression: Expression,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the inequality comparison.

### Example

```typescript
// Check if the 'status' field is not equal to "completed"
notEqual(field("status"), "completed");

```

### round(expression)

Creates an expression that rounds a numeric value to the nearest whole number.

**Signature:**

```typescript
export declare function round(expression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric value, which will be rounded. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the rounded value.

### Example

```typescript
// Round the value of the 'price' field.
round(field("price"));

```

### round(expression, decimalPlaces)

Creates an expression that rounds a numeric value to the specified number of decimal places.

**Signature:**

```typescript
export declare function round(
  expression: Expression,
  decimalPlaces: number | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric value, which will be rounded. |
| decimalPlaces | number \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | A constant or expression specifying the rounding precision in decimal places. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the rounded value.

### Example

```typescript
// Round the value of the 'price' field to two decimal places.
round(field("price"), constant(2));

```

### rtrim(expression, valueToTrim)

Trims whitespace or a specified set of characters/bytes from the end of a string or byte array.

**Signature:**

```typescript
export declare function rtrim(
  expression: Expression,
  valueToTrim?: string | Expression | Bytes
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string or byte array. |
| valueToTrim | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | Optional. A string or byte array containing the characters/bytes to trim. If not specified, whitespace will be trimmed. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the trimmed string or byte array.

### Example

```typescript
// Trim whitespace from the end of the 'userInput' field
rtrim(field("userInput"));

// Trim quotes from the end of the 'userInput' field
rtrim(field("userInput"), '"');

```

### split(expression, delimiter)

Creates an expression that splits a string into an array of substrings based on the provided delimiter.

**Signature:**

```typescript
export declare function split(
  expression: Expression,
  delimiter: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Split the result of this expression. |
| delimiter | string | Split on this delimiter. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the split function.

### Example

```typescript
// Split the 'scoresCsv' field on delimiter ','
split(field('scoresCsv'), ',')

```

### split(expression, delimiter)

Creates an expression that splits a string into an array of substrings based on the provided delimiter.

**Signature:**

```typescript
export declare function split(
  expression: Expression,
  delimiter: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Split the result of this expression. |
| delimiter | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Split on this delimiter returned by evaluating this expression. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the split function.

### Example

```typescript
// Split the 'scores' field on delimiter ',' or ':' depending on the stored format
split(field('scores'), conditional(field('format').equal('csv'), constant(','), constant(':')))

```

### sqrt(expression)

Creates an expression that computes the square root of a numeric value.

**Signature:**

```typescript
export declare function sqrt(expression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric value, which the square root will be computed for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the square root of the numeric value.

### Example

```typescript
// Compute the square root of the 'value' field.
sqrt(field("value"));

```

### stringIndexOf(expression, search)

Creates an expression that finds the index of the first occurrence of a substring or byte sequence.

**Signature:**

```typescript
export declare function stringIndexOf(
  expression: Expression,
  search: string | Expression | Bytes
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string or byte array. |
| search | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The substring or byte sequence to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the index of the first occurrence.

### Example

```typescript
// Find the index of "foo" in the 'text' field
stringIndexOf(field("text"), "foo");

```

### stringRepeat(expression, repetitions)

Creates an expression that repeats a string or byte array a specified number of times.

**Signature:**

```typescript
export declare function stringRepeat(
  expression: Expression,
  repetitions: number | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string or byte array. |
| repetitions | number \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The number of times to repeat the string or byte array. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the repeated string or byte array.

### Example

```typescript
// Repeat the 'label' field 3 times
stringRepeat(field("label"), 3);

```

### stringReplaceAll(expression, find, replacement)

Creates an expression that replaces all occurrences of a substring or byte sequence with a replacement.

**Signature:**

```typescript
export declare function stringReplaceAll(
  expression: Expression,
  find: string | Expression | Bytes,
  replacement: string | Expression | Bytes
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string or byte array. |
| find | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The substring or byte sequence to search for. |
| replacement | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The replacement string or byte sequence. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the string or byte array with replacements.

### Example

```typescript
// Replace all occurrences of "foo" with "bar" in the 'text' field
stringReplaceAll(field("text"), "foo", "bar");

```

### stringReplaceOne(expression, find, replacement)

Creates an expression that replaces the first occurrence of a substring or byte sequence with a replacement.

**Signature:**

```typescript
export declare function stringReplaceOne(
  expression: Expression,
  find: string | Expression | Bytes,
  replacement: string | Expression | Bytes
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string or byte array. |
| find | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The substring or byte sequence to search for. |
| replacement | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The replacement string or byte sequence. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the string or byte array with the replacement.

### Example

```typescript
// Replace the first occurrence of "foo" with "bar" in the 'text' field
stringReplaceOne(field("text"), "foo", "bar");

```

### subtract(expression, value)

Creates an expression that subtracts a constant value from an expression.

**Signature:**

```typescript
export declare function subtract(
  expression: Expression,
  value: unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to subtract from. |
| value | unknown | The constant value to subtract. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the subtraction operation.

### Example

```typescript
// Subtract the constant value 2 from the 'value' field
subtract(field("value"), 2);

```

### sum(expression)

Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs.

**Signature:**

```typescript
export declare function sum(expression: Expression): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to sum up. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'sum' aggregation.

### Example

```typescript
// Calculate the total revenue from a set of orders
sum(field("orderAmount")).as("totalRevenue");

```

### trunc(expression)

Creates an expression that truncates the numeric value of an expression to an integer.

**Signature:**

```typescript
export declare function trunc(expression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric value, which will be truncated. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the truncated value.

### Example

```typescript
// Truncate the value of the 'rating' field.
trunc(field("rating"));

```

### trunc(expression, decimalPlaces)

Creates an expression that truncates a numeric value to the specified number of decimal places.

**Signature:**

```typescript
export declare function trunc(
  expression: Expression,
  decimalPlaces: number | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a numeric value, which will be truncated. |
| decimalPlaces | number \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | A constant or expression specifying the truncation precision in decimal places. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the truncated value.

### Example

```typescript
// Truncate the value of the 'rating' field to two decimal places.
trunc(field("rating"), constant(2));

```

### type(expression)

Creates an expression that returns the data type of an expression's result.

**Signature:**

```typescript
export declare function type(expression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) |   |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the data type.

### Example

```typescript
// Get the data type of a conditional expression
type(conditional(exists('foo'), constant(1), constant(true)))

```

## function(field, ...)

### isAbsent(field)

Creates an expression that returns `true` if a field is absent. Otherwise, returns `false` even if the field value is `null`.

**Signature:**

```typescript
export declare function isAbsent(field: string): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| field | string | The field to check. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'isAbsent' check.

### Example

```typescript
// Check if the field `value` is absent.
isAbsent("value");

```

### reverse(field)

Creates an expression that reverses a string value in the specified field.

**Signature:**

```typescript
export declare function reverse(field: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| field | string | The name of the field representing the string to reverse. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the reversed string.

### Example

```typescript
// Reverse the value of the 'myString' field.
reverse("myString");

```

### stringReverse(field)

Creates an expression that reverses a string value in the specified field.

**Signature:**

```typescript
export declare function stringReverse(field: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| field | string | The name of the field representing the string to reverse. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the reversed string.

### Example

```typescript
// Reverse the value of the 'myString' field.
stringReverse("myString");

```

### substring(field, position, length)

Creates an expression that returns a substring of a string or byte array.

**Signature:**

```typescript
export declare function substring(
  field: string,
  position: number,
  length?: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| field | string | The name of a field containing a string or byte array to compute the substring from. |
| position | number | Index of the first character of the substring. |
| length | number | Length of the substring. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

### substring(field, position, length)

Creates an expression that returns a substring of a string or byte array.

**Signature:**

```typescript
export declare function substring(
  field: string,
  position: Expression,
  length?: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| field | string | The name of a field containing a string or byte array to compute the substring from. |
| position | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that returns the index of the first character of the substring. |
| length | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that returns the length of the substring. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

## function(fieldName, ...)

### abs(fieldName)

Creates an expression that computes the absolute value of a numeric value.

**Signature:**

```typescript
export declare function abs(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field to compute the absolute value of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the absolute value of the numeric value.

### add(fieldName, second)

Creates an expression that adds a field's value to an expression.

**Signature:**

```typescript
export declare function add(
  fieldName: string,
  second: Expression | unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the value to add. |
| second | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The second expression or literal to add. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the addition operation.

### Example

```typescript
// Add the value of the 'quantity' field and the 'reserve' field.
add("quantity", field("reserve"));

```

### arrayAgg(fieldName)

Creates an aggregation that collects all values of a field across multiple stage inputs into an array.

If the expression resolves to an absent value, it is converted to `null`. The order of elements in the output array is not stable and shouldn't be relied upon.

**Signature:**

```typescript
export declare function arrayAgg(fieldName: string): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to collect values from. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'array_agg' aggregation.

### Example

```typescript
// Collect all tags from books into an array
arrayAgg("tags").as("allTags");

```

### arrayAggDistinct(fieldName)

Creates an aggregation that collects all distinct values of a field across multiple stage inputs into an array.

If the expression resolves to an absent value, it is converted to `null`. The order of elements in the output array is not stable and shouldn't be relied upon.

**Signature:**

```typescript
export declare function arrayAggDistinct(fieldName: string): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to collect values from. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'array_agg_distinct' aggregation.

### Example

```typescript
// Collect all distinct tags from books into an array
arrayAggDistinct("tags").as("allDistinctTags");

```

### arrayContains(fieldName, element)

Creates an expression that checks if a field's array value contains a specific element.

**Signature:**

```typescript
export declare function arrayContains(
  fieldName: string,
  element: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |
| element | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The element to search for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains' comparison.

### Example

```typescript
// Check if the 'colors' array contains the value of field 'selectedColor'
arrayContains("colors", field("selectedColor"));

```

### arrayContains(fieldName, element)

Creates an expression that checks if a field's array value contains a specific value.

**Signature:**

```typescript
export declare function arrayContains(
  fieldName: string,
  element: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |
| element | unknown | The element to search for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains' comparison.

### Example

```typescript
// Check if the 'colors' array contains "red"
arrayContains("colors", "red");

```

### arrayContainsAll(fieldName, values)

Creates an expression that checks if a field's array value contains all the specified values or expressions.

**Signature:**

```typescript
export declare function arrayContainsAll(
  fieldName: string,
  values: Array<Expression | unknown>
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |
| values | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | The elements to check for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains_all' comparison.

### Example

```typescript
// Check if the 'tags' array contains both of the values from field 'tag1', the value "SciFi", and "Adventure"
arrayContainsAll("tags", [field("tag1"), "SciFi", "Adventure"]);

```

### arrayContainsAll(fieldName, arrayExpression)

Creates an expression that checks if a field's array value contains all the specified values or expressions.

**Signature:**

```typescript
export declare function arrayContainsAll(
  fieldName: string,
  arrayExpression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The elements to check for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains_all' comparison.

### Example

```typescript
// Check if the 'tags' array contains both of the values from field 'tag1', the value "SciFi", and "Adventure"
arrayContainsAll("tags", [field("tag1"), "SciFi", "Adventure"]);

```

### arrayContainsAny(fieldName, values)

Creates an expression that checks if a field's array value contains any of the specified elements.

**Signature:**

```typescript
export declare function arrayContainsAny(
  fieldName: string,
  values: Array<Expression | unknown>
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |
| values | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | The elements to check for in the array. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains_any' comparison.

### Example

```typescript
// Check if the 'groups' array contains either the value from the 'userGroup' field
// or the value "guest"
arrayContainsAny("categories", [field("cate1"), "Science"]);

```

### arrayContainsAny(fieldName, values)

Creates an expression that checks if a field's array value contains any of the specified elements.

**Signature:**

```typescript
export declare function arrayContainsAny(
  fieldName: string,
  values: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |
| values | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that evaluates to an array, whose elements to check for in the array field. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'array_contains_any' comparison.

### Example

```typescript
// Check if the 'groups' array contains either the value from the 'userGroup' field
// or the value "guest"
arrayContainsAny("categories", array([field("cate1"), "Science"]));

```

### arrayFilter(fieldName, alias, filter)

Creates an expression that filters an array using a provided alias and predicate expression.

**Signature:**

```typescript
export declare function arrayFilter(
  fieldName: string,
  alias: string,
  filter: BooleanExpression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| alias | string | The variable name to use for each element. |
| filter | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The predicate boolean expression to evaluate for each element. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the filtered array.

### Example

```typescript
// Get a filtered array of the 'scores' field containing only elements greater than 50.
arrayFilter("scores", "score", greaterThan(variable("score"), 50));

```

### arrayFirst(fieldName)

Creates an expression that returns the first element of an array.

**Signature:**

```typescript
export declare function arrayFirst(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the first element.

### Example

```typescript
// Get the first tag from the 'tags' array field
arrayFirst("tags");

```

### arrayFirstN(fieldName, n)

Creates an expression that returns the first `n` elements of an array.

**Signature:**

```typescript
export declare function arrayFirstN(
  fieldName: string,
  n: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| n | number | The number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the first `n` elements.

### Example

```typescript
// Get the first 3 tags from the 'tags' array field
arrayFirstN("tags", 3);

```

### arrayFirstN(fieldName, n)

Creates an expression that returns the first `n` elements of an array.

**Signature:**

```typescript
export declare function arrayFirstN(
  fieldName: string,
  n: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| n | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to the number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the first `n` elements.

### Example

```typescript
// Get the first n tags from the 'tags' array field
arrayFirstN("tags", field("count"));

```

### arrayIndexOf(fieldName, search)

Creates an expression that returns the first index of the search value in an array. Returns -1 if the value is not found.

**Signature:**

```typescript
export declare function arrayIndexOf(
  fieldName: string,
  search: unknown | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array to search. |
| search | unknown \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The value to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the index.

### Example

```typescript
// Get the index of "politics" in the 'tags' array field
arrayIndexOf("tags", "politics");

```

### arrayIndexOfAll(fieldName, search)

Creates an expression that returns all indices of the search value in an array.

**Signature:**

```typescript
export declare function arrayIndexOfAll(
  fieldName: string,
  search: unknown | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array to search. |
| search | unknown \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The value to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the indices.

### Example

```typescript
// Get all indices of 5 in the 'scores' array field
arrayIndexOfAll("scores", 5);

```

### arrayLast(fieldName)

Creates an expression that returns the last element of an array.

**Signature:**

```typescript
export declare function arrayLast(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the last element.

### Example

```typescript
// Get the last tag from the 'tags' array field
arrayLast("tags");

```

### arrayLastIndexOf(fieldName, search)

Creates an expression that returns the last index of the search value in an array. Returns -1 if the value is not found.

**Signature:**

```typescript
export declare function arrayLastIndexOf(
  fieldName: string,
  search: unknown | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array to search. |
| search | unknown \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The value to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the index.

### Example

```typescript
// Get the last index of "politics" in the 'tags' array field
arrayLastIndexOf("tags", "politics");

```

### arrayLastN(fieldName, n)

Creates an expression that returns the last `n` elements of an array.

**Signature:**

```typescript
export declare function arrayLastN(
  fieldName: string,
  n: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| n | number | The number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the last `n` elements.

### Example

```typescript
// Get the last 3 tags from the 'tags' array field
arrayLastN("tags", 3);

```

### arrayLastN(fieldName, n)

Creates an expression that returns the last `n` elements of an array.

**Signature:**

```typescript
export declare function arrayLastN(
  fieldName: string,
  n: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| n | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to the number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the last `n` elements.

### Example

```typescript
// Get the last n tags from the 'tags' array field
arrayLastN("tags", field("count"));

```

### arrayLength(fieldName)

Creates an expression that calculates the length of an array in a specified field.

**Signature:**

```typescript
export declare function arrayLength(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing an array to calculate the length of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the length of the array.

### Example

```typescript
// Get the number of items in field 'cart'
arrayLength('cart');

```

### arrayMaximum(fieldName)

Creates an expression that returns the maximum value in an array.

**Signature:**

```typescript
export declare function arrayMaximum(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the maximum value.

### Example

```typescript
// Get the maximum value from the 'scores' array field
arrayMaximum("scores");

```

### arrayMaximumN(fieldName, n)

Creates an expression that returns the largest `n` elements of an array.

> [!NOTE]
> **Note:** Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.

**Signature:**

```typescript
export declare function arrayMaximumN(
  fieldName: string,
  n: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| n | number | The number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the largest `n` elements.

### Example

```typescript
// Get the top 3 scores from the 'scores' array field
arrayMaximumN("scores", 3);

```

### arrayMaximumN(fieldName, n)

Creates an expression that returns the largest `n` elements of an array.

> [!NOTE]
> **Note:** Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.

**Signature:**

```typescript
export declare function arrayMaximumN(
  fieldName: string,
  n: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| n | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to the number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the largest `n` elements.

### Example

```typescript
// Get the top n scores from the 'scores' array field
arrayMaximumN("scores", field("count"));

```

### arrayMinimum(fieldName)

Creates an expression that returns the minimum value in an array.

**Signature:**

```typescript
export declare function arrayMinimum(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the minimum value.

### Example

```typescript
// Get the minimum value from the 'scores' array field
arrayMinimum("scores");

```

### arrayMinimumN(fieldName, n)

Creates an expression that returns the smallest `n` elements of an array.

> [!NOTE]
> **Note:** Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.

**Signature:**

```typescript
export declare function arrayMinimumN(
  fieldName: string,
  n: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| n | number | The number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the smallest `n` elements.

### Example

```typescript
// Get the bottom 3 scores from the 'scores' array field
arrayMinimumN("scores", 3);

```

### arrayMinimumN(fieldName, n)

Creates an expression that returns the smallest `n` elements of an array.

> [!NOTE]
> **Note:** Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.

**Signature:**

```typescript
export declare function arrayMinimumN(
  fieldName: string,
  n: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| n | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to the number of elements to return. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the smallest `n` elements.

### Example

```typescript
// Get the bottom n scores from the 'scores' array field
arrayMinimumN(field("scores"), field("count"));

```

### arraySlice(fieldName, offset, length)

Creates an expression that returns a slice of an array from `offset` with `length` elements.

**Signature:**

```typescript
export declare function arraySlice(
  fieldName: string,
  offset: number | Expression,
  length?: number | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| offset | number \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The starting offset. |
| length | number \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The optional length of the slice. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the sliced array.

### Example

```typescript
// Get 5 elements from the 'items' array field starting from index 2
arraySlice("items", 2, 5);

// Get n elements from the 'items' array field starting from index 2
arraySlice("items", 2, field("length"));

```

### arraySum(fieldName)

Creates an expression that computes the sum of the elements in an array.

**Signature:**

```typescript
export declare function arraySum(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to compute the sum of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the sum of the elements in the array.

### Example

```typescript
// Compute the sum of the elements in the 'scores' field.
arraySum("scores");

```

### arrayTransform(fieldName, elementAlias, transform)

Creates an expression that applies a provided transformation to each element in an array.

**Signature:**

```typescript
export declare function arrayTransform(
  fieldName: string,
  elementAlias: string,
  transform: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| elementAlias | string | The variable name to use for each element. |
| transform | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression used to transform the elements. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the transformed array.

### Example

```typescript
// Transform "scores" array by multiplying each score by 10
arrayTransform("scores", "score", multiply(variable("score"), 10));

```

### arrayTransformWithIndex(fieldName, elementAlias, indexAlias, transform)

Creates an expression that applies a provided transformation to each element in an array, providing the element's index to the transformation expression.

**Signature:**

```typescript
export declare function arrayTransformWithIndex(
  fieldName: string,
  elementAlias: string,
  indexAlias: string,
  transform: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the array. |
| elementAlias | string | The variable name to use for each element. |
| indexAlias | string | The variable name to use for the current index. |
| transform | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The lambda expression used to transform the elements. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the transformed array.

### Example

```typescript
// Transform "scores" array by adding the index to each score
arrayTransformWithIndex("scores", "score", "i", add(variable("score"), variable("i")));

```

### ascending(fieldName)

Creates an [Ordering](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.ordering.md.txt#ordering_class) that sorts documents in ascending order based on a field.

**Signature:**

```typescript
export declare function ascending(fieldName: string): Ordering;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field to create an ascending ordering for. |

**Returns:**

[Ordering](https://firebase.google.com/docs/reference/js/firestore_pipelines.ordering.md.txt#ordering_class)

A new `Ordering` for ascending sorting.

### Example

```typescript
// Sort documents by the 'name' field in ascending order
firestore.pipeline().collection("users")
  .sort(ascending("name"));

```

### average(fieldName)

Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs.

**Signature:**

```typescript
export declare function average(fieldName: string): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing numeric values to average. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'average' aggregation.

### Example

```typescript
// Calculate the average age of users
average("age").as("averageAge");

```

### byteLength(fieldName)

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.

**Signature:**

```typescript
export declare function byteLength(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the length of the string in bytes.

### Example

```typescript
// Calculate the length of the 'myString' field in bytes.
byteLength("myString");

```

### ceil(fieldName)

Creates an expression that computes the ceiling of a numeric value.

**Signature:**

```typescript
export declare function ceil(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to compute the ceiling of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the ceiling of the numeric value.

### Example

```typescript
// Compute the ceiling of the 'price' field.
ceil("price");

```

### charLength(fieldName)

Creates an expression that calculates the character length of a string field in UTF8.

**Signature:**

```typescript
export declare function charLength(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the length of the string.

### Example

```typescript
// Get the character length of the 'name' field in UTF-8.
charLength("name");

```

### coalesce(fieldName, replacement, others)

Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument.

**Signature:**

```typescript
export declare function coalesce(
  fieldName: string,
  replacement: Expression | unknown,
  ...others: Array<Expression | unknown>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the first field to check for null. |
| replacement | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The fallback expression or value if the first one is null. |
| others | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | Optional additional expressions to check if previous ones are null. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the coalesce operation.

### Example

```typescript
// Returns the value of the first non-null, non-absent field among 'preferredName', 'fullName',
// or the last argument if all previous fields are null.
coalesce("preferredName", field("fullName"), constant("Anonymous"))

```

### collectionId(fieldName)

Creates an expression that returns the collection ID from a path.

**Signature:**

```typescript
export declare function collectionId(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to get the collection ID from. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the collectionId operation.

### Example

```typescript
// Get the collection ID from a path.
collectionId("__name__");

```

### concat(fieldName, second, others)

Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed.

**Signature:**

```typescript
export declare function concat(
  fieldName: string,
  second: Expression | unknown,
  ...others: Array<Expression | unknown>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of a field to concatenate. |
| second | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The second literal or expression to concatenate. |
| others | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | Additional literal or expressions to concatenate. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the concatenation.

### Example

```typescript
// Concatenate a field with a literal string.
concat(field("firstName"), "Doe")

```

### cosineDistance(fieldName, vector)

Calculates the Cosine distance between a field's vector value and a literal vector value.

**Signature:**

```typescript
export declare function cosineDistance(
  fieldName: string,
  vector: number[] | VectorValue
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the first vector. |
| vector | number\[\] \| [VectorValue](https://firebase.google.com/docs/reference/js/firestore.vectorvalue.md.txt#vectorvalue_class) | The other vector (as an array of doubles) or [VectorValue](https://firebase.google.com/docs/reference/js/firestore.vectorvalue.md.txt#vectorvalue_class) to compare against. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the Cosine distance between the two vectors.

### Example

```typescript
// Calculate the Cosine distance between the 'location' field and a target location
cosineDistance("location", [37.7749, -122.4194]);

```

### cosineDistance(fieldName, vectorExpression)

Calculates the Cosine distance between a field's vector value and a vector expression.

**Signature:**

```typescript
export declare function cosineDistance(
  fieldName: string,
  vectorExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the first vector. |
| vectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The other vector (represented as an `Expression`) to compare against. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the cosine distance between the two vectors.

### Example

```typescript
// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field
cosineDistance("userVector", field("itemVector"));

```

### count(fieldName)

Creates an aggregation that counts the number of stage inputs where the input field exists.

**Signature:**

```typescript
export declare function count(fieldName: string): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to count. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'count' aggregation.

### Example

```typescript
// Count the total number of products
count("productId").as("totalProducts");

```

### descending(fieldName)

Creates an [Ordering](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.ordering.md.txt#ordering_class) that sorts documents in descending order based on a field.

**Signature:**

```typescript
export declare function descending(fieldName: string): Ordering;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field to create a descending ordering for. |

**Returns:**

[Ordering](https://firebase.google.com/docs/reference/js/firestore_pipelines.ordering.md.txt#ordering_class)

A new `Ordering` for descending sorting.

### Example

```typescript
// Sort documents by the 'name' field in descending order
firestore.pipeline().collection("users")
  .sort(descending("name"));

```

### divide(fieldName, expressions)

Creates an expression that divides a field's value by an expression.

**Signature:**

```typescript
export declare function divide(
  fieldName: string,
  expressions: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to be divided. |
| expressions | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to divide by. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the division operation.

### Example

```typescript
// Divide the 'total' field by the 'count' field
divide("total", field("count"));

```

### divide(fieldName, value)

Creates an expression that divides a field's value by a constant value.

**Signature:**

```typescript
export declare function divide(
  fieldName: string,
  value: unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to be divided. |
| value | unknown | The constant value to divide by. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the division operation.

### Example

```typescript
// Divide the 'value' field by 10
divide("value", 10);

```

### dotProduct(fieldName, vector)

Calculates the dot product between a field's vector value and a double array.

**Signature:**

```typescript
export declare function dotProduct(
  fieldName: string,
  vector: number[] | VectorValue
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the first vector. |
| vector | number\[\] \| [VectorValue](https://firebase.google.com/docs/reference/js/firestore.vectorvalue.md.txt#vectorvalue_class) | The other vector (as an array of doubles or VectorValue) to calculate with. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the dot product between the two vectors.

### Example

```typescript
// Calculate the dot product distance between a feature vector and a target vector
dotProduct("features", [0.5, 0.8, 0.2]);

```

### dotProduct(fieldName, vectorExpression)

Calculates the dot product between a field's vector value and a vector expression.

**Signature:**

```typescript
export declare function dotProduct(
  fieldName: string,
  vectorExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the first vector. |
| vectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The other vector (represented as an `Expression`) to calculate with. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the dot product between the two vectors.

### Example

```typescript
// Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2'
dotProduct("docVector1", field("docVector2"));

```

### endsWith(fieldName, suffix)

Creates an expression that checks if a field's value ends with a given postfix.

**Signature:**

```typescript
export declare function endsWith(
  fieldName: string,
  suffix: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |
| suffix | string | The postfix to check for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'ends with' comparison.

### Example

```typescript
// Check if the 'filename' field ends with ".txt"
endsWith("filename", ".txt");

```

### endsWith(fieldName, suffix)

Creates an expression that checks if a field's value ends with a given postfix.

**Signature:**

```typescript
export declare function endsWith(
  fieldName: string,
  suffix: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |
| suffix | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the postfix. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'ends with' comparison.

### Example

```typescript
// Check if the 'url' field ends with the value of the 'extension' field
endsWith("url", field("extension"));

```

### equal(fieldName, expression)

Creates an expression that checks if a field's value is equal to an expression.

**Signature:**

```typescript
export declare function equal(
  fieldName: string,
  expression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the equality comparison.

### Example

```typescript
// Check if the 'age' field is equal to the 'limit' field
equal("age", field("limit"));

```

### equal(fieldName, value)

Creates an expression that checks if a field's value is equal to a constant value.

**Signature:**

```typescript
export declare function equal(
  fieldName: string,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the equality comparison.

### Example

```typescript
// Check if the 'city' field is equal to string constant "London"
equal("city", "London");

```

### equalAny(fieldName, values)

Creates an expression that checks if a field's value is equal to any of the provided values or expressions.

**Signature:**

```typescript
export declare function equalAny(
  fieldName: string,
  values: Array<Expression | unknown>
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field to compare. |
| values | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | The values to check against. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'IN' comparison.

### Example

```typescript
// Check if the 'category' field is either "Electronics" or value of field 'primaryType'
equalAny("category", [constant("Electronics"), field("primaryType")]);

```

### equalAny(fieldName, arrayExpression)

Creates an expression that checks if a field's value is equal to any of the provided values or expressions.

**Signature:**

```typescript
export declare function equalAny(
  fieldName: string,
  arrayExpression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field to compare. |
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that evaluates to an array, whose elements to check for equality to the input field. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'IN' comparison.

### Example

```typescript
// Check if the 'category' field is either "Electronics" or value of field 'primaryType'
equalAny("category", ["Electronics", field("primaryType")]);

```

### euclideanDistance(fieldName, vector)

Calculates the Euclidean distance between a field's vector value and a double array.

**Signature:**

```typescript
export declare function euclideanDistance(
  fieldName: string,
  vector: number[] | VectorValue
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the first vector. |
| vector | number\[\] \| [VectorValue](https://firebase.google.com/docs/reference/js/firestore.vectorvalue.md.txt#vectorvalue_class) | The other vector (as an array of doubles or VectorValue) to compare against. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the Euclidean distance between the two vectors.

### Example

```typescript
// Calculate the Euclidean distance between the 'location' field and a target location
euclideanDistance("location", [37.7749, -122.4194]);

```

### euclideanDistance(fieldName, vectorExpression)

Calculates the Euclidean distance between a field's vector value and a vector expression.

**Signature:**

```typescript
export declare function euclideanDistance(
  fieldName: string,
  vectorExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the first vector. |
| vectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The other vector (represented as an `Expression`) to compare against. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the Euclidean distance between the two vectors.

### Example

```typescript
// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB'
euclideanDistance("pointA", field("pointB"));

```

### exists(fieldName)

Creates an expression that checks if a field exists.

**Signature:**

```typescript
export declare function exists(fieldName: string): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'exists' check.

### Example

```typescript
// Check if the document has a field named "phoneNumber"
exists("phoneNumber");

```

### exp(fieldName)

Creates an expression that computes e to the power of the expression's result.

**Signature:**

```typescript
export declare function exp(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string |   |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the exp of the numeric value.

### Example

```typescript
// Compute e to the power of the 'value' field.
exp('value');

```

### first(fieldName)

Creates an aggregation that finds the first value of a field across multiple stage inputs.

**Signature:**

```typescript
export declare function first(fieldName: string): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to find the first value of. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'first' aggregation.

### Example

```typescript
// Find the first value of the 'rating' field
first("rating").as("firstRating");

```

### floor(fieldName)

Creates an expression that computes the floor of a numeric value.

**Signature:**

```typescript
export declare function floor(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to compute the floor of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the floor of the numeric value.

### geoDistance(fieldName, location)

Evaluates to the distance in meters between the location in the specified field and the query location.

This Expression can only be used within a `search` stage.

**Signature:**

```typescript
export declare function geoDistance(
  fieldName: string | Field,
  location: GeoPoint | Expression
): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string \| [Field](https://firebase.google.com/docs/reference/js/firestore_pipelines.field.md.txt#field_class) | Specifies the field in the document which contains the first GeoPoint for distance computation. |
| location | [GeoPoint](https://firebase.google.com/docs/reference/js/firestore.geopoint.md.txt#geopoint_class) \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Compute distance to this GeoPoint. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

### Example

```typescript
db.pipeline().collection('restaurants').search({
  query: 'waffles',
  sort: geoDistance('location', new GeoPoint(37.0, -122.0)).ascending()
})

```

### greaterThan(fieldName, expression)

Creates an expression that checks if a field's value is greater than an expression.

**Signature:**

```typescript
export declare function greaterThan(
  fieldName: string,
  expression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the greater than comparison.

### Example

```typescript
// Check if the value of field 'age' is greater than the value of field 'limit'
greaterThan("age", field("limit"));

```

### greaterThan(fieldName, value)

Creates an expression that checks if a field's value is greater than a constant value.

**Signature:**

```typescript
export declare function greaterThan(
  fieldName: string,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the greater than comparison.

### Example

```typescript
// Check if the 'price' field is greater than 100
greaterThan("price", 100);

```

### greaterThanOrEqual(fieldName, value)

Creates an expression that checks if a field's value is greater than or equal to an expression.

**Signature:**

```typescript
export declare function greaterThanOrEqual(
  fieldName: string,
  value: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| value | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the greater than or equal to comparison.

### Example

```typescript
// Check if the value of field 'age' is greater than or equal to the value of field 'limit'
greaterThanOrEqual("age", field("limit"));

```

### greaterThanOrEqual(fieldName, value)

Creates an expression that checks if a field's value is greater than or equal to a constant value.

**Signature:**

```typescript
export declare function greaterThanOrEqual(
  fieldName: string,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the greater than or equal to comparison.

### Example

```typescript
// Check if the 'score' field is greater than or equal to 80
greaterThanOrEqual("score", 80);

```

### isType(fieldName, type)

Creates an expression that checks if the value in the specified field is of the given type.

Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data. Supported values for `type` are: `'null'`, `'array'`, `'boolean'`, `'bytes'`, `'timestamp'`, `'geo_point'`, `'number'`, `'int32'`, `'int64'`, `'float64'`, `'decimal128'`, `'map'`, `'reference'`, `'string'`, `'vector'`, `'max_key'`, `'min_key'`, `'object_id'`, `'regex'`, `'request_timestamp'`.

**Signature:**

```typescript
export declare function isType(
  fieldName: string,
  type: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to check. |
| type | string | The type to check for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `BooleanExpression` that evaluates to true if the field's value is of the given type, false otherwise.

### Example

```typescript
// Check if the 'price' field is a floating point number (evaluating to true inside pipeline conditionals)
isType('price', 'float64');

```

### last(fieldName)

Creates an aggregation that finds the last value of a field across multiple stage inputs.

**Signature:**

```typescript
export declare function last(fieldName: string): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to find the last value of. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'last' aggregation.

### Example

```typescript
// Find the last value of the 'rating' field
last("rating").as("lastRating");

```

### length_2(fieldName)

Creates an expression that calculates the length of a string, array, map, vector, or bytes.

**Signature:**

```typescript
declare function length_2(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to calculate the length of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the length of the string, array, map, vector, or bytes.

### Example

```typescript
// Get the length of the 'name' field.
length("name");

// Get the number of items in the 'cart' array.
length("cart");

```

### lessThan(fieldName, expression)

Creates an expression that checks if a field's value is less than an expression.

**Signature:**

```typescript
export declare function lessThan(
  fieldName: string,
  expression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the less than comparison.

### Example

```typescript
// Check if the 'age' field is less than the 'limit' field
lessThan("age", field("limit"));

```

### lessThan(fieldName, value)

Creates an expression that checks if a field's value is less than a constant value.

**Signature:**

```typescript
export declare function lessThan(
  fieldName: string,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the less than comparison.

### Example

```typescript
// Check if the 'price' field is less than 50
lessThan("price", 50);

```

### lessThanOrEqual(fieldName, expression)

Creates an expression that checks if a field's value is less than or equal to an expression.

**Signature:**

```typescript
export declare function lessThanOrEqual(
  fieldName: string,
  expression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the less than or equal to comparison.

### Example

```typescript
// Check if the 'quantity' field is less than or equal to the 'limit' field
lessThan("quantity", field("limit"));

```

### lessThanOrEqual(fieldName, value)

Creates an expression that checks if a field's value is less than or equal to a constant value.

**Signature:**

```typescript
export declare function lessThanOrEqual(
  fieldName: string,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the less than or equal to comparison.

### Example

```typescript
// Check if the 'score' field is less than or equal to 70
lessThan("score", 70);

```

### like(fieldName, pattern)

Creates an expression that performs a case-sensitive wildcard string comparison against a field.

**Signature:**

```typescript
export declare function like(
  fieldName: string,
  pattern: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |
| pattern | string | The pattern to search for. You can use "%" as a wildcard character. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'like' comparison.

### Example

```typescript
// Check if the 'title' field contains the string "guide"
like("title", "%guide%");

```

### like(fieldName, pattern)

Creates an expression that performs a case-sensitive wildcard string comparison against a field.

**Signature:**

```typescript
export declare function like(
  fieldName: string,
  pattern: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |
| pattern | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The pattern to search for. You can use "%" as a wildcard character. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'like' comparison.

### Example

```typescript
// Check if the 'title' field contains the string "guide"
like("title", field("pattern"));

```

### ln(fieldName)

Creates an expression that computes the natural logarithm of a numeric value.

**Signature:**

```typescript
export declare function ln(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to compute the natural logarithm of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the natural logarithm of the numeric value.

### Example

```typescript
// Compute the natural logarithm of the 'value' field.
ln("value");

```

### log(fieldName, base)

Creates an expression that computes the logarithm of a field to a given base.

**Signature:**

```typescript
export declare function log(
  fieldName: string,
  base: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to compute the logarithm of. |
| base | number | The base of the logarithm. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logarithm of the numeric value.

### Example

```typescript
// Compute the logarithm of the 'value' field with base 10.
log("value", 10);

```

### log(fieldName, base)

Creates an expression that computes the logarithm of a field to a given base.

**Signature:**

```typescript
export declare function log(
  fieldName: string,
  base: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to compute the logarithm of. |
| base | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The base of the logarithm. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logarithm of the numeric value.

### Example

```typescript
// Compute the logarithm of the 'value' field with the base in the 'base' field.
log("value", field("base"));

```

### log10(fieldName)

Creates an expression that computes the base-10 logarithm of a numeric value.

**Signature:**

```typescript
export declare function log10(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to compute the base-10 logarithm of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the base-10 logarithm of the numeric value.

### Example

```typescript
// Compute the base-10 logarithm of the 'value' field.
log10("value");

```

### logicalMaximum(fieldName, second, others)

Creates an expression that returns the largest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

**Signature:**

```typescript
export declare function logicalMaximum(
  fieldName: string,
  second: Expression | unknown,
  ...others: Array<Expression | unknown>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The first operand field name. |
| second | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The second expression or literal. |
| others | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | Optional additional expressions or literals. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logical maximum operation.

### Example

```typescript
// Returns the largest value between the 'field1' field, the 'field2' field,
// and 1000.
logicalMaximum("field1", field("field2"), 1000);

```

### logicalMinimum(fieldName, second, others)

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.

**Signature:**

```typescript
export declare function logicalMinimum(
  fieldName: string,
  second: Expression | unknown,
  ...others: Array<Expression | unknown>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The first operand field name. |
| second | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The second expression or literal. |
| others | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | Optional additional expressions or literals. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logical minimum operation.

### Example

```typescript
// Returns the smallest value between the 'field1' field, the 'field2' field,
// and 1000.
logicalMinimum("field1", field("field2"), 1000);

```

### ltrim(fieldName, valueToTrim)

Trims whitespace or a specified set of characters/bytes from the beginning of a string or byte array.

**Signature:**

```typescript
export declare function ltrim(
  fieldName: string,
  valueToTrim?: string | Expression | Bytes
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string or byte array. |
| valueToTrim | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | Optional. A string or byte array containing the characters/bytes to trim. If not specified, whitespace will be trimmed. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the trimmed string or byte array.

### Example

```typescript
// Trim whitespace from the beginning of the 'userInput' field
ltrim(field("userInput"));

// Trim quotes from the beginning of the 'userInput' field
ltrim(field("userInput"), '"');

```

### mapGet(fieldName, subField)

Accesses a value from a map (object) field using the provided key.

**Signature:**

```typescript
export declare function mapGet(
  fieldName: string,
  subField: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name of the map field. |
| subField | string | The key to access in the map. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the value associated with the given key in the map.

### Example

```typescript
// Get the 'city' value from the 'address' map field
mapGet("address", "city");

```

### maximum(fieldName)

Creates an aggregation that finds the maximum value of a field across multiple stage inputs.

**Signature:**

```typescript
export declare function maximum(fieldName: string): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to find the maximum value of. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'maximum' aggregation.

### Example

```typescript
// Find the highest score in a leaderboard
maximum("score").as("highestScore");

```

### minimum(fieldName)

Creates an aggregation that finds the minimum value of a field across multiple stage inputs.

**Signature:**

```typescript
export declare function minimum(fieldName: string): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to find the minimum value of. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'minimum' aggregation.

### Example

```typescript
// Find the lowest price of all products
minimum("price").as("lowestPrice");

```

### mod(fieldName, expression)

Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression.

**Signature:**

```typescript
export declare function mod(
  fieldName: string,
  expression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The dividend field name. |
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The divisor expression. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the modulo operation.

### Example

```typescript
// Calculate the remainder of dividing 'field1' by 'field2'.
mod("field1", field("field2"));

```

### mod(fieldName, value)

Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant.

**Signature:**

```typescript
export declare function mod(
  fieldName: string,
  value: unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The dividend field name. |
| value | unknown | The divisor constant. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the modulo operation.

### Example

```typescript
// Calculate the remainder of dividing 'field1' by 5.
mod("field1", 5);

```

### multiply(fieldName, second)

Creates an expression that multiplies a field's value by an expression.

**Signature:**

```typescript
export declare function multiply(
  fieldName: string,
  second: Expression | unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the value to add. |
| second | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The second expression or literal to add. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the multiplication operation.

### Example

```typescript
// Multiply the 'quantity' field by the 'price' field
multiply("quantity", field("price"));

```

### notEqual(fieldName, expression)

Creates an expression that checks if a field's value is not equal to an expression.

**Signature:**

```typescript
export declare function notEqual(
  fieldName: string,
  expression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the inequality comparison.

### Example

```typescript
// Check if the 'status' field is not equal to the value of 'expectedStatus'
notEqual("status", field("expectedStatus"));

```

### notEqual(fieldName, value)

Creates an expression that checks if a field's value is not equal to a constant value.

**Signature:**

```typescript
export declare function notEqual(
  fieldName: string,
  value: unknown
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| value | unknown | The constant value to compare to. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the inequality comparison.

### Example

```typescript
// Check if the 'country' field is not equal to "USA"
notEqual("country", "USA");

```

### notEqualAny(fieldName, values)

Creates an expression that checks if a field's value is not equal to any of the provided values or expressions.

**Signature:**

```typescript
export declare function notEqualAny(
  fieldName: string,
  values: Array<Expression | unknown>
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| values | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | The values to check against. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'NOT IN' comparison.

### Example

```typescript
// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus'
notEqualAny("status", [constant("pending"), field("rejectedStatus")]);

```

### notEqualAny(fieldName, arrayExpression)

Creates an expression that checks if a field's value is not equal to any of the values in the evaluated expression.

**Signature:**

```typescript
export declare function notEqualAny(
  fieldName: string,
  arrayExpression: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to compare. |
| arrayExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The values to check against. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'NOT IN' comparison.

### Example

```typescript
// Check if the 'status' field is not equal to any value in the field 'rejectedStatuses'
notEqualAny("status", field("rejectedStatuses"));

```

### regexContains(fieldName, pattern)

Creates an expression that checks if a string field contains a specified regular expression as a substring.

**Signature:**

```typescript
export declare function regexContains(
  fieldName: string,
  pattern: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |
| pattern | string | The regular expression to use for the search. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'contains' comparison.

### Example

```typescript
// Check if the 'description' field contains "example" (case-insensitive)
regexContains("description", "(?i)example");

```

### regexContains(fieldName, pattern)

Creates an expression that checks if a string field contains a specified regular expression as a substring.

**Signature:**

```typescript
export declare function regexContains(
  fieldName: string,
  pattern: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |
| pattern | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The regular expression to use for the search. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'contains' comparison.

### Example

```typescript
// Check if the 'description' field contains "example" (case-insensitive)
regexContains("description", field("pattern"));

```

### regexFind(fieldName, pattern)

Creates an expression that returns the first substring of a string field that matches a specified regular expression.

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

**Signature:**

```typescript
export declare function regexFind(
  fieldName: string,
  pattern: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string to search. |
| pattern | string | The regular expression to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the regular expression find function.

### Example

```typescript
// Extract the domain name from an email field
regexFind("email", "@[A-Za-z0-9.-]+");

```

### regexFind(fieldName, pattern)

Creates an expression that returns the first substring of a string field that matches a specified regular expression.

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

**Signature:**

```typescript
export declare function regexFind(
  fieldName: string,
  pattern: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string to search. |
| pattern | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The regular expression to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the regular expression find function.

### Example

```typescript
// Extract a substring from 'email' based on a pattern stored in another field
regexFind("email", field("pattern"));

```

### regexFindAll(fieldName, pattern)

Creates an expression that evaluates to a list of all substrings in a string field that match a specified regular expression.

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

**Signature:**

```typescript
export declare function regexFindAll(
  fieldName: string,
  pattern: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string to search. |
| pattern | string | The regular expression to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.functionexpression.md.txt#functionexpression_class) that evaluates to an array of matched substrings.

### Example

```typescript
// Extract all hashtags from a post content field
regexFindAll("content", "#[A-Za-z0-9_]+");

```

### regexFindAll(fieldName, pattern)

Creates an expression that evaluates to a list of all substrings in a string field that match a specified regular expression.

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

**Signature:**

```typescript
export declare function regexFindAll(
  fieldName: string,
  pattern: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string to search. |
| pattern | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The regular expression to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.functionexpression.md.txt#functionexpression_class) that evaluates to an array of matched substrings.

### Example

```typescript
// Extract all matches from 'content' based on a pattern stored in another field
regexFindAll("content", field("pattern"));

```

### regexMatch(fieldName, pattern)

Creates an expression that checks if a string field matches a specified regular expression.

**Signature:**

```typescript
export declare function regexMatch(
  fieldName: string,
  pattern: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |
| pattern | string | The regular expression to use for the match. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the regular expression match.

### Example

```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(fieldName, pattern)

Creates an expression that checks if a string field matches a specified regular expression.

**Signature:**

```typescript
export declare function regexMatch(
  fieldName: string,
  pattern: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |
| pattern | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The regular expression to use for the match. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the regular expression match.

### Example

```typescript
// Check if the 'email' field matches a valid email pattern
regexMatch("email", field("pattern"));

```

### round(fieldName)

Creates an expression that rounds a numeric value to the nearest whole number.

**Signature:**

```typescript
export declare function round(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to round. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the rounded value.

### Example

```typescript
// Round the value of the 'price' field.
round("price");

```

### round(fieldName, decimalPlaces)

Creates an expression that rounds a numeric value to the specified number of decimal places.

**Signature:**

```typescript
export declare function round(
  fieldName: string,
  decimalPlaces: number | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to round. |
| decimalPlaces | number \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | A constant or expression specifying the rounding precision in decimal places. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the rounded value.

### Example

```typescript
// Round the value of the 'price' field to two decimal places.
round("price", 2);

```

### rtrim(fieldName, valueToTrim)

Trims whitespace or a specified set of characters/bytes from the end of a string or byte array.

**Signature:**

```typescript
export declare function rtrim(
  fieldName: string,
  valueToTrim?: string | Expression | Bytes
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string or byte array. |
| valueToTrim | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | Optional. A string or byte array containing the characters/bytes to trim. If not specified, whitespace will be trimmed. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the trimmed string or byte array.

### Example

```typescript
// Trim whitespace from the end of the 'userInput' field
rtrim(field("userInput"));

// Trim quotes from the end of the 'userInput' field
rtrim(field("userInput"), '"');

```

### split(fieldName, delimiter)

Creates an expression that splits the value of a field on the provided delimiter.

**Signature:**

```typescript
export declare function split(
  fieldName: string,
  delimiter: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | Split the value in this field. |
| delimiter | string | Split on this delimiter. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the split function.

### Example

```typescript
// Split the 'scoresCsv' field on delimiter ','
split('scoresCsv', ',')

```

### split(fieldName, delimiter)

Creates an expression that splits the value of a field on the provided delimiter.

**Signature:**

```typescript
export declare function split(
  fieldName: string,
  delimiter: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | Split the value in this field. |
| delimiter | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Split on this delimiter returned by evaluating this expression. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the split function.

### Example

```typescript
// Split the 'scores' field on delimiter ',' or ':' depending on the stored format
split('scores', conditional(field('format').equal('csv'), constant(','), constant(':')))

```

### sqrt(fieldName)

Creates an expression that computes the square root of a numeric value.

**Signature:**

```typescript
export declare function sqrt(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to compute the square root of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the square root of the numeric value.

### Example

```typescript
// Compute the square root of the 'value' field.
sqrt("value");

```

### startsWith(fieldName, prefix)

Creates an expression that checks if a field's value starts with a given prefix.

**Signature:**

```typescript
export declare function startsWith(
  fieldName: string,
  prefix: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |
| prefix | string | The prefix to check for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'starts with' comparison.

### Example

```typescript
// Check if the 'name' field starts with "Mr."
startsWith("name", "Mr.");

```

### startsWith(fieldName, prefix)

Creates an expression that checks if a field's value starts with a given prefix.

**Signature:**

```typescript
export declare function startsWith(
  fieldName: string,
  prefix: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to check. |
| prefix | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the prefix. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'starts with' comparison.

### Example

```typescript
// Check if the 'fullName' field starts with the value of the 'firstName' field
startsWith("fullName", field("firstName"));

```

### stringConcat(fieldName, secondString, otherStrings)

Creates an expression that concatenates string functions, fields or constants together.

**Signature:**

```typescript
export declare function stringConcat(
  fieldName: string,
  secondString: Expression | string,
  ...otherStrings: Array<Expression | string>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name containing the initial string value. |
| secondString | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| string | An expression or string literal to concatenate. |
| otherStrings | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| string\> | Optional additional expressions or literals (typically strings) to concatenate. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the concatenated string.

### Example

```typescript
// Combine the 'firstName', " ", and 'lastName' fields into a single string
stringConcat("firstName", " ", field("lastName"));

```

### stringContains(fieldName, substring)

Creates an expression that checks if a string field contains a specified substring.

**Signature:**

```typescript
export declare function stringContains(
  fieldName: string,
  substring: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |
| substring | string | The substring to search for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'contains' comparison.

### Example

```typescript
// Check if the 'description' field contains "example".
stringContains("description", "example");

```

### stringContains(fieldName, substring)

Creates an expression that checks if a string field contains a substring specified by an expression.

**Signature:**

```typescript
export declare function stringContains(
  fieldName: string,
  substring: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |
| substring | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the substring to search for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'contains' comparison.

### Example

```typescript
// Check if the 'description' field contains the value of the 'keyword' field.
stringContains("description", field("keyword"));

```

### stringIndexOf(fieldName, search)

Creates an expression that finds the index of the first occurrence of a substring or byte sequence.

**Signature:**

```typescript
export declare function stringIndexOf(
  fieldName: string,
  search: string | Expression | Bytes
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string or byte array. |
| search | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The substring or byte sequence to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the index of the first occurrence.

### Example

```typescript
// Find the index of "foo" in the 'text' field
stringIndexOf("text", "foo");

```

### stringRepeat(fieldName, repetitions)

Creates an expression that repeats a string or byte array a specified number of times.

**Signature:**

```typescript
export declare function stringRepeat(
  fieldName: string,
  repetitions: number | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string or byte array. |
| repetitions | number \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The number of times to repeat the string or byte array. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the repeated string or byte array.

### Example

```typescript
// Repeat the 'label' field 3 times
stringRepeat("label", 3);

```

### stringReplaceAll(fieldName, find, replacement)

Creates an expression that replaces all occurrences of a substring or byte sequence with a replacement.

**Signature:**

```typescript
export declare function stringReplaceAll(
  fieldName: string,
  find: string | Expression | Bytes,
  replacement: string | Expression | Bytes
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string or byte array. |
| find | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The substring or byte sequence to search for. |
| replacement | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The replacement string or byte sequence. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the string or byte array with replacements.

### Example

```typescript
// Replace all occurrences of "foo" with "bar" in the 'text' field
stringReplaceAll("text", "foo", "bar");

```

### stringReplaceOne(fieldName, find, replacement)

Creates an expression that replaces the first occurrence of a substring or byte sequence with a replacement.

**Signature:**

```typescript
export declare function stringReplaceOne(
  fieldName: string,
  find: string | Expression | Bytes,
  replacement: string | Expression | Bytes
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string or byte array. |
| find | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The substring or byte sequence to search for. |
| replacement | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The replacement string or byte sequence. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the string or byte array with the replacement.

### Example

```typescript
// Replace the first occurrence of "foo" with "bar" in the 'text' field
stringReplaceOne("text", "foo", "bar");

```

### subtract(fieldName, expression)

Creates an expression that subtracts an expression from a field's value.

**Signature:**

```typescript
export declare function subtract(
  fieldName: string,
  expression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to subtract from. |
| expression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to subtract. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the subtraction operation.

### Example

```typescript
// Subtract the 'discount' field from the 'price' field
subtract("price", field("discount"));

```

### subtract(fieldName, value)

Creates an expression that subtracts a constant value from a field's value.

**Signature:**

```typescript
export declare function subtract(
  fieldName: string,
  value: unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The field name to subtract from. |
| value | unknown | The constant value to subtract. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the subtraction operation.

### Example

```typescript
// Subtract 20 from the value of the 'total' field
subtract("total", 20);

```

### sum(fieldName)

Creates an aggregation that calculates the sum of a field's values across multiple stage inputs.

**Signature:**

```typescript
export declare function sum(fieldName: string): AggregateFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing numeric values to sum up. |

**Returns:**

[AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aggregatefunction.md.txt#aggregatefunction_class)

A new [AggregateFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aggregatefunction.md.txt#aggregatefunction_class) representing the 'sum' aggregation.

### Example

```typescript
// Calculate the total revenue from a set of orders
sum("orderAmount").as("totalRevenue");

```

### timestampAdd(fieldName, unit, amount)

Creates an expression that adds a specified amount of time to a timestamp represented by a field.

**Signature:**

```typescript
export declare function timestampAdd(
  fieldName: string,
  unit: TimeUnit,
  amount: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the timestamp. |
| unit | [TimeUnit](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timeunit) | The unit of time to add (e.g., "day", "hour"). |
| amount | number | The amount of time to add. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the resulting timestamp.

### Example

```typescript
// Add 1 day to the 'timestamp' field.
timestampAdd("timestamp", "day", 1);

```

### timestampExtract(fieldName, part, timezone)

Creates an expression that extracts a specified part from a timestamp.

**Signature:**

```typescript
export declare function timestampExtract(
  fieldName: string,
  part: TimePart,
  timezone?: string | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the timestamp. |
| part | [TimePart](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timepart) | The part to extract from the timestamp (e.g., "year", "month", "day"). |
| timezone | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The timezone to use for extraction. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1." |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the extracted part as an integer.

### Example

```typescript
// Extract the year from the 'createdAt' timestamp.
timestampExtract('createdAt', 'year')

```

### timestampExtract(fieldName, part, timezone)

Creates an expression that extracts a specified part from a timestamp.

**Signature:**

```typescript
export declare function timestampExtract(
  fieldName: string,
  part: Expression,
  timezone?: string | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the timestamp. |
| part | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression evaluating to the part to extract. |
| timezone | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The timezone to use for extraction. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1." |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the extracted part as an integer.

### Example

```typescript
// Extract the part specified by the field 'part' from 'createdAt'.
timestampExtract('createdAt', field('part'))

```

### timestampSubtract(fieldName, unit, amount)

Creates an expression that subtracts a specified amount of time from a timestamp represented by a field.

**Signature:**

```typescript
export declare function timestampSubtract(
  fieldName: string,
  unit: TimeUnit,
  amount: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the timestamp. |
| unit | [TimeUnit](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timeunit) | The unit of time to subtract (e.g., "day", "hour"). |
| amount | number | The amount of time to subtract. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the resulting timestamp.

### Example

```typescript
// Subtract 1 day from the 'timestamp' field.
timestampSubtract("timestamp", "day", 1);

```

### timestampToUnixMicros(fieldName)

Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

**Signature:**

```typescript
export declare function timestampToUnixMicros(
  fieldName: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the timestamp. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the number of microseconds since epoch.

### Example

```typescript
// Convert the 'timestamp' field to microseconds since epoch.
timestampToUnixMicros("timestamp");

```

### timestampToUnixMillis(fieldName)

Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

**Signature:**

```typescript
export declare function timestampToUnixMillis(
  fieldName: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the timestamp. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the number of milliseconds since epoch.

### Example

```typescript
// Convert the 'timestamp' field to milliseconds since epoch.
timestampToUnixMillis("timestamp");

```

### timestampToUnixSeconds(fieldName)

Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).

**Signature:**

```typescript
export declare function timestampToUnixSeconds(
  fieldName: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the timestamp. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the number of seconds since epoch.

### Example

```typescript
// Convert the 'timestamp' field to seconds since epoch.
timestampToUnixSeconds("timestamp");

```

### timestampTruncate(fieldName, granularity, timezone)

Creates an expression that truncates a timestamp to a specified granularity.

**Signature:**

```typescript
export declare function timestampTruncate(
  fieldName: string,
  granularity: TimeGranularity,
  timezone?: string | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | Truncate the timestamp value contained in this field. |
| granularity | [TimeGranularity](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timegranularity) | The granularity to truncate to. |
| timezone | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the truncated timestamp.

### Example

```typescript
// Truncate the 'createdAt' timestamp to the beginning of the day.
timestampTruncate('createdAt', 'day')

```

### timestampTruncate(fieldName, granularity, timezone)

Creates an expression that truncates a timestamp to a specified granularity.

**Signature:**

```typescript
export declare function timestampTruncate(
  fieldName: string,
  granularity: Expression,
  timezone?: string | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | Truncate the timestamp value contained in this field. |
| granularity | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The granularity to truncate to. |
| timezone | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the truncated timestamp.

### Example

```typescript
// Truncate the 'createdAt' timestamp to the granularity specified in the field 'granularity'.
timestampTruncate('createdAt', field('granularity'))

```

### toLower(fieldName)

Creates an expression that converts a string field to lowercase.

**Signature:**

```typescript
export declare function toLower(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the lowercase string.

### Example

```typescript
// Convert the 'name' field to lowercase
toLower("name");

```

### toUpper(fieldName)

Creates an expression that converts a string field to uppercase.

**Signature:**

```typescript
export declare function toUpper(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the uppercase string.

### Example

```typescript
// Convert the 'title' field to uppercase
toUpper("title");

```

### trim(fieldName, valueToTrim)

Creates an expression that removes leading and trailing whitespace from a string or byte array.

**Signature:**

```typescript
export declare function trim(
  fieldName: string,
  valueToTrim?: string | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the string or byte array. |
| valueToTrim | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Optional This parameter is treated as a set of characters or bytes that will be trimmed from the input. If not specified, then whitespace will be trimmed. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the trimmed string.

### Example

```typescript
// Trim whitespace from the 'userInput' field
trim("userInput");

// Trim quotes from the 'userInput' field
trim("userInput", '"');

```

### trunc(fieldName)

Creates an expression that truncates the numeric value of a field to an integer.

**Signature:**

```typescript
export declare function trunc(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field containing the number to truncate. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the truncated value.

### Example

```typescript
// Truncate the value of the 'rating' field
trunc("rating");

```

### trunc(fieldName, decimalPlaces)

Creates an expression that truncates a numeric expression to the specified number of decimal places.

**Signature:**

```typescript
export declare function trunc(
  fieldName: string,
  decimalPlaces: number | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field to truncate. |
| decimalPlaces | number \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | A constant or expression specifying the truncation precision in decimal places. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the truncated value.

### Example

```typescript
// Truncate the value of the 'rating' field to two decimal places.
trunc("rating", 2);

```

### type(fieldName)

Creates an expression that returns the data type of the data in the specified field.

String inputs passed iteratively to this global function act as `field()` path lookups. If you wish to pass a string literal value, it must be wrapped: `type(constant("my_string"))`.

**Signature:**

```typescript
export declare function type(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string |   |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the data type.

### Example

```typescript
// Get the data type of the value in field 'title'
type('title')

```

### unixMicrosToTimestamp(fieldName)

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.

**Signature:**

```typescript
export declare function unixMicrosToTimestamp(
  fieldName: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the number of microseconds since epoch. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the timestamp.

### Example

```typescript
// Interpret the 'microseconds' field as microseconds since epoch.
unixMicrosToTimestamp("microseconds");

```

### unixMillisToTimestamp(fieldName)

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.

**Signature:**

```typescript
export declare function unixMillisToTimestamp(
  fieldName: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the number of milliseconds since epoch. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the timestamp.

### Example

```typescript
// Interpret the 'milliseconds' field as milliseconds since epoch.
unixMillisToTimestamp("milliseconds");

```

### unixSecondsToTimestamp(fieldName)

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.

**Signature:**

```typescript
export declare function unixSecondsToTimestamp(
  fieldName: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the number of seconds since epoch. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the timestamp.

### Example

```typescript
// Interpret the 'seconds' field as seconds since epoch.
unixSecondsToTimestamp("seconds");

```

### vectorLength(fieldName)

Creates an expression that calculates the length of a Firestore Vector represented by a field.

**Signature:**

```typescript
export declare function vectorLength(fieldName: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| fieldName | string | The name of the field representing the Firestore Vector. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the length of the array.

### Example

```typescript
// Get the vector length (dimension) of the field 'embedding'.
vectorLength("embedding");

```

## function(first, ...)

### add(first, second)

Creates an expression that adds two expressions together.

**Signature:**

```typescript
export declare function add(
  first: Expression,
  second: Expression | unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| first | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first expression to add. |
| second | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The second expression or literal to add. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the addition operation.

### Example

```typescript
// Add the value of the 'quantity' field and the 'reserve' field.
add(field("quantity"), field("reserve"));

```

### and(first, second, more)

Creates an expression that performs a logical 'AND' operation on multiple filter conditions.

**Signature:**

```typescript
export declare function and(
  first: BooleanExpression,
  second: BooleanExpression,
  ...more: BooleanExpression[]
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| first | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The first filter condition. |
| second | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The second filter condition. |
| more | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)\[\] | Additional filter conditions to 'AND' together. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logical 'AND' operation.

### Example

```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(greaterThan("age", 18), equal("city", "London"), equal("status", "active"));

```

### concat(first, second, others)

Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed.

**Signature:**

```typescript
export declare function concat(
  first: Expression,
  second: Expression | unknown,
  ...others: Array<Expression | unknown>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| first | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first expressions to concatenate. |
| second | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The second literal or expression to concatenate. |
| others | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | Additional literals or expressions to concatenate. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the concatenation.

### Example

```typescript
// Concatenate the 'firstName' and 'lastName' fields with a space in between.
concat(field("firstName"), " ", field("lastName"))

```

### logicalMaximum(first, second, others)

Creates an expression that returns the largest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

**Signature:**

```typescript
export declare function logicalMaximum(
  first: Expression,
  second: Expression | unknown,
  ...others: Array<Expression | unknown>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| first | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first operand expression. |
| second | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The second expression or literal. |
| others | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | Optional additional expressions or literals. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logical maximum operation.

### Example

```typescript
// Returns the largest value between the 'field1' field, the 'field2' field,
// and 1000
logicalMaximum(field("field1"), field("field2"), 1000);

```

### logicalMinimum(first, second, others)

Creates an expression that returns the smallest value between multiple input expressions and literal values. Based on Firestore's value type ordering.

**Signature:**

```typescript
export declare function logicalMinimum(
  first: Expression,
  second: Expression | unknown,
  ...others: Array<Expression | unknown>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| first | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first operand expression. |
| second | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The second expression or literal. |
| others | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\> | Optional additional expressions or literals. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logical minimum operation.

### Example

```typescript
// Returns the smallest value between the 'field1' field, the 'field2' field,
// and 1000.
logicalMinimum(field("field1"), field("field2"), 1000);

```

### multiply(first, second)

Creates an expression that multiplies two expressions together.

**Signature:**

```typescript
export declare function multiply(
  first: Expression,
  second: Expression | unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| first | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first expression to multiply. |
| second | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The second expression or literal to multiply. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the multiplication operation.

### Example

```typescript
// Multiply the 'quantity' field by the 'price' field
multiply(field("quantity"), field("price"));

```

### nor(first, second, more)

Creates an expression that performs a logical 'NOR' operation on multiple filter conditions.

**Signature:**

```typescript
export declare function nor(
  first: BooleanExpression,
  second: BooleanExpression,
  ...more: BooleanExpression[]
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| first | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The first filter condition. |
| second | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The second filter condition. |
| more | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)\[\] | Additional filter conditions to 'NOR' together. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.booleanexpression.md.txt#booleanexpression_class) representing the logical 'NOR' operation.

### Example

```typescript
// Check if neither the 'age' field is greater than 18 nor the 'city' field is "London"
const condition = nor(
  greaterThan("age", 18),
  equal("city", "London")
);

```

### or(first, second, more)

Creates an expression that performs a logical 'OR' operation on multiple filter conditions.

**Signature:**

```typescript
export declare function or(
  first: BooleanExpression,
  second: BooleanExpression,
  ...more: BooleanExpression[]
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| first | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The first filter condition. |
| second | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The second filter condition. |
| more | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)\[\] | Additional filter conditions to 'OR' together. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logical 'OR' operation.

### Example

```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(greaterThan("age", 18), equal("city", "London"), equal("status", "active"));

```

### xor(first, second, additionalConditions)

Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple BooleanExpressions.

**Signature:**

```typescript
export declare function xor(
  first: BooleanExpression,
  second: BooleanExpression,
  ...additionalConditions: BooleanExpression[]
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| first | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The first condition. |
| second | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The second condition. |
| additionalConditions | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)\[\] | Additional conditions to 'XOR' together. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the logical 'XOR' operation.

### Example

```typescript
// Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London",
// or 'status' is "active".
const condition = xor(
    greaterThan("age", 18),
    equal("city", "London"),
    equal("status", "active"));

```

## function(firstArray, ...)

### arrayConcat(firstArray, secondArray, otherArrays)

Creates an expression that concatenates an array expression with other arrays.

**Signature:**

```typescript
export declare function arrayConcat(
  firstArray: Expression,
  secondArray: Expression | unknown[],
  ...otherArrays: Array<Expression | unknown[]>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| firstArray | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first array expression to concatenate to. |
| secondArray | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\[\] | The second array expression or array literal to concatenate to. |
| otherArrays | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\[\]\> | Optional additional array expressions or array literals to concatenate. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the concatenated array.

### Example

```typescript
// Combine the 'items' array with two new item arrays
arrayConcat(field("items"), [field("newItems"), field("otherItems")]);

```

## function(firstArrayField, ...)

### arrayConcat(firstArrayField, secondArray, otherArrays)

Creates an expression that concatenates a field's array value with other arrays.

**Signature:**

```typescript
export declare function arrayConcat(
  firstArrayField: string,
  secondArray: Expression | unknown[],
  ...otherArrays: Array<Expression | unknown[]>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| firstArrayField | string | The first array to concatenate to. |
| secondArray | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\[\] | The second array expression or array literal to concatenate to. |
| otherArrays | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown\[\]\> | Optional additional array expressions or array literals to concatenate. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the concatenated array.

### Example

```typescript
// Combine the 'items' array with two new item arrays
arrayConcat("items", [field("newItems"), field("otherItems")]);

```

## function(firstMap, ...)

### mapMerge(firstMap, secondMap, otherMaps)

Creates an expression that merges multiple map values.

**Signature:**

```typescript
export declare function mapMerge(
  firstMap: Record<string, unknown> | Expression,
  secondMap: Record<string, unknown> | Expression,
  ...otherMaps: Array<Record<string, unknown> | Expression>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| firstMap | Record\<string, unknown\> \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression or literal map value that will be merged. |
| secondMap | Record\<string, unknown\> \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | A required second map to merge. Represented as a literal or an expression that returns a map. |
| otherMaps | Array\<Record\<string, unknown\> \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)\> | Optional additional maps to merge. Each map is represented as a literal or an expression that returns a map. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

### Example

```typescript
// 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 }, conditional(field('isAdmin'), { admin: true}, {})

```

## function(firstString, ...)

### stringConcat(firstString, secondString, otherStrings)

Creates an expression that concatenates string expressions together.

**Signature:**

```typescript
export declare function stringConcat(
  firstString: Expression,
  secondString: Expression | string,
  ...otherStrings: Array<Expression | string>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| firstString | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The initial string expression to concatenate to. |
| secondString | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| string | An expression or string literal to concatenate. |
| otherStrings | Array\<[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| string\> | Optional additional expressions or literals (typically strings) to concatenate. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the concatenated string.

### Example

```typescript
// Combine the 'firstName', " ", and 'lastName' fields into a single string
stringConcat(field("firstName"), " ", field("lastName"));

```

## function(ifExpr, ...)

### ifAbsent(ifExpr, elseExpr)

Creates an expression that returns the `elseExpr` argument if `ifExpr` is absent, else return the result of the `ifExpr` argument evaluation.

**Signature:**

```typescript
export declare function ifAbsent(
  ifExpr: Expression,
  elseExpr: Expression
): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ifExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check for absence. |
| elseExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression that will be evaluated and returned if \[ifExpr\] is absent. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new Expression representing the ifAbsent operation.

### Example

```typescript
// Returns the value of the optional field 'optional_field', or returns 'default_value'
// if the field is absent.
ifAbsent(field("optional_field"), constant("default_value"))

```

### ifAbsent(ifExpr, elseValue)

Creates an expression that returns the `elseValue` argument if `ifExpr` is absent, else return the result of the `ifExpr` argument evaluation.

**Signature:**

```typescript
export declare function ifAbsent(
  ifExpr: Expression,
  elseValue: unknown
): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ifExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check for absence. |
| elseValue | unknown | The value that will be returned if `ifExpr` evaluates to an absent value. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new \[Expression\] representing the ifAbsent operation.

### Example

```typescript
// Returns the value of the optional field 'optional_field', or returns 'default_value'
// if the field is absent.
ifAbsent(field("optional_field"), "default_value")

```

### ifNull(ifExpr, elseExpr)

Creates an expression that returns the `elseExpr` argument if `ifExpr` is null, else return the result of the `ifExpr` argument evaluation.

This function provides a fallback for both absent and explicit null values. In contrast, `ifAbsent()` only triggers for missing fields.

**Signature:**

```typescript
export declare function ifNull(
  ifExpr: Expression,
  elseExpr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ifExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check for null. |
| elseExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression that will be evaluated and returned if `ifExpr` is null. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the ifNull operation.

### Example

```typescript
// Returns the user's preferred name, or if that is null, returns their full name.
ifNull(field("preferredName"), field("fullName"))

```

### ifNull(ifExpr, elseValue)

Creates an expression that returns the `elseValue` argument if `ifExpr` is null, else return the result of the `ifExpr` argument evaluation.

This function provides a fallback for both absent and explicit null values. In contrast, `ifAbsent()` only triggers for missing fields.

**Signature:**

```typescript
export declare function ifNull(
  ifExpr: Expression,
  elseValue: unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ifExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check for null. |
| elseValue | unknown | The value that will be returned if `ifExpr` evaluates to null. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the ifNull operation.

### Example

```typescript
// Returns the user's display name, or returns "Anonymous" if the field is null.
ifNull(field("displayName"), "Anonymous")

```

## function(ifFieldName, ...)

### ifAbsent(ifFieldName, elseExpr)

Creates an expression that returns the `elseExpr` argument if `ifFieldName` is absent, else return the value of the field.

**Signature:**

```typescript
export declare function ifAbsent(
  ifFieldName: string,
  elseExpr: Expression
): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ifFieldName | string | The field to check for absence. |
| elseExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression that will be evaluated and returned if `ifFieldName` is absent. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new Expression representing the ifAbsent operation.

### Example

```typescript
// Returns the value of the optional field 'optional_field', or returns the value of
// 'default_field' if 'optional_field' is absent.
ifAbsent("optional_field", field("default_field"))

```

### ifAbsent(ifFieldName, elseValue)

Creates an expression that returns the `elseValue` argument if `ifFieldName` is absent, else return the value of the field.

**Signature:**

```typescript
export declare function ifAbsent(
  ifFieldName: string | Expression,
  elseValue: Expression | unknown
): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ifFieldName | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The field to check for absence. |
| elseValue | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) \| unknown | The value that will be returned if \[ifFieldName\] is absent. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new Expression representing the ifAbsent operation.

### Example

```typescript
// Returns the value of the optional field 'optional_field', or returns 'default_value'
// if the field is absent.
ifAbsent("optional_field", "default_value")

```

### ifNull(ifFieldName, elseExpr)

Creates an expression that returns the `elseExpr` argument if `ifFieldName` field is null, else return the value of the field.

This function provides a fallback for both absent and explicit null values. In contrast, `ifAbsent()` only triggers for missing fields.

**Signature:**

```typescript
export declare function ifNull(
  ifFieldName: string,
  elseExpr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ifFieldName | string | The field to check for null. |
| elseExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression that will be evaluated and returned if `ifFieldName` is null. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the ifNull operation.

### Example

```typescript
// Returns the user's preferred name, or if that is null, returns their full name.
ifNull("preferredName", field("fullName"))

```

### ifNull(ifFieldName, elseValue)

Creates an expression that returns the `elseValue` argument if `ifFieldName` field is null, else return the value of the field.

This function provides a fallback for both absent and explicit null values. In contrast, `ifAbsent()` only triggers for missing fields.

**Signature:**

```typescript
export declare function ifNull(
  ifFieldName: string,
  elseValue: unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ifFieldName | string | The field to check for null. |
| elseValue | unknown | The value that will be returned if `ifFieldName` is null. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the ifNull operation.

### Example

```typescript
// Returns the user's display name, or returns "Anonymous" if the field is null.
ifNull("displayName", "Anonymous")

```

## function(input, ...)

### substring(input, position, length)

Creates an expression that returns a substring of a string or byte array.

**Signature:**

```typescript
export declare function substring(
  input: Expression,
  position: number,
  length?: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| input | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression returning a string or byte array to compute the substring from. |
| position | number | Index of the first character of the substring. |
| length | number | Length of the substring. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

### substring(input, position, length)

Creates an expression that returns a substring of a string or byte array.

**Signature:**

```typescript
export declare function substring(
  input: Expression,
  position: Expression,
  length?: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| input | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression returning a string or byte array to compute the substring from. |
| position | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that returns the index of the first character of the substring. |
| length | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that returns the length of the substring. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

## function(left, ...)

### divide(left, right)

Creates an expression that divides two expressions.

**Signature:**

```typescript
export declare function divide(
  left: Expression,
  right: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| left | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to be divided. |
| right | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to divide by. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the division operation.

### Example

```typescript
// Divide the 'total' field by the 'count' field
divide(field("total"), field("count"));

```

### equal(left, right)

Creates an expression that checks if two expressions are equal.

**Signature:**

```typescript
export declare function equal(
  left: Expression,
  right: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| left | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first expression to compare. |
| right | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The second expression to compare. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the equality comparison.

### Example

```typescript
// Check if the 'age' field is equal to an expression
equal(field("age"), field("minAge").add(10));

```

### greaterThan(left, right)

Creates an expression that checks if the first expression is greater than the second expression.

**Signature:**

```typescript
export declare function greaterThan(
  left: Expression,
  right: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| left | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first expression to compare. |
| right | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The second expression to compare. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the greater than comparison.

### Example

```typescript
// Check if the 'age' field is greater than 18
greaterThan(field("age"), constant(9).add(9));

```

### greaterThanOrEqual(left, right)

Creates an expression that checks if the first expression is greater than or equal to the second expression.

**Signature:**

```typescript
export declare function greaterThanOrEqual(
  left: Expression,
  right: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| left | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first expression to compare. |
| right | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The second expression to compare. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the greater than or equal to comparison.

### Example

```typescript
// Check if the 'quantity' field is greater than or equal to the field "threshold"
greaterThanOrEqual(field("quantity"), field("threshold"));

```

### lessThan(left, right)

Creates an expression that checks if the first expression is less than the second expression.

**Signature:**

```typescript
export declare function lessThan(
  left: Expression,
  right: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| left | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first expression to compare. |
| right | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The second expression to compare. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the less than comparison.

### Example

```typescript
// Check if the 'age' field is less than 30
lessThan(field("age"), field("limit"));

```

### lessThanOrEqual(left, right)

Creates an expression that checks if the first expression is less than or equal to the second expression.

**Signature:**

```typescript
export declare function lessThanOrEqual(
  left: Expression,
  right: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| left | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first expression to compare. |
| right | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The second expression to compare. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the less than or equal to comparison.

### Example

```typescript
// Check if the 'quantity' field is less than or equal to 20
lessThan(field("quantity"), field("limit"));

```

### mod(left, right)

Creates an expression that calculates the modulo (remainder) of dividing two expressions.

**Signature:**

```typescript
export declare function mod(
  left: Expression,
  right: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| left | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The dividend expression. |
| right | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The divisor expression. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the modulo operation.

### Example

```typescript
// Calculate the remainder of dividing 'field1' by 'field2'.
mod(field("field1"), field("field2"));

```

### notEqual(left, right)

Creates an expression that checks if two expressions are not equal.

**Signature:**

```typescript
export declare function notEqual(
  left: Expression,
  right: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| left | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first expression to compare. |
| right | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The second expression to compare. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Expression` representing the inequality comparison.

### Example

```typescript
// Check if the 'status' field is not equal to field 'finalState'
notEqual(field("status"), field("finalState"));

```

### pipelineResultEqual(left, right)

Test equality of two PipelineResults.

**Signature:**

```typescript
export declare function pipelineResultEqual(
  left: PipelineResult,
  right: PipelineResult
): boolean;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| left | [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipelineresult.md.txt#pipelineresult_class) | First PipelineResult to compare. |
| right | [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipelineresult.md.txt#pipelineresult_class) | Second PipelineResult to compare. |

**Returns:**

boolean

### subtract(left, right)

Creates an expression that subtracts two expressions.

**Signature:**

```typescript
export declare function subtract(
  left: Expression,
  right: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| left | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to subtract from. |
| right | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to subtract. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the subtraction operation.

### Example

```typescript
// Subtract the 'discount' field from the 'price' field
subtract(field("price"), field("discount"));

```

## function(mapExpr, ...)

### mapRemove(mapExpr, key)

Creates an expression that removes a key from the map produced by evaluating an expression.

**Signature:**

```typescript
export declare function mapRemove(
  mapExpr: Expression,
  key: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression return a map value. |
| key | string | The name of the key to remove from the input map. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

### Example

```typescript
// Removes the key 'baz' from the input map.
mapRemove(map({foo: 'bar', baz: true}), 'baz');

```

### mapRemove(mapExpr, keyExpr)

Creates an expression that removes a key from the map produced by evaluating an expression.

**Signature:**

```typescript
export declare function mapRemove(
  mapExpr: Expression,
  keyExpr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression return a map value. |
| keyExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that produces the name of the key to remove from the input map. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

### Example

```typescript
// Removes the key 'baz' from the input map.
mapRemove(map({foo: 'bar', baz: true}), constant('baz'));

```

## function(mapExpression, ...)

### mapEntries(mapExpression)

Creates an expression that returns the entries of a map as an array of maps, where each map contains a `"k"` property for the key and a `"v"` property for the value. For example: `[{ k: "key1", v: "value1" }, ...]`.

While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.

**Signature:**

```typescript
export declare function mapEntries(
  mapExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the map to get the entries of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the entries of the map.

### Example

```typescript
// Get the entries of the map expression
mapEntries(map({"city": "San Francisco"}));

```

### mapGet(mapExpression, subField)

Accesses a value from a map (object) expression using the provided key.

**Signature:**

```typescript
export declare function mapGet(
  mapExpression: Expression,
  subField: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the map. |
| subField | string | The key to access in the map. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the value associated with the given key in the map.

### Example

```typescript
// Get the 'city' value from the 'address' map field
mapGet(field("address"), "city");

```

### mapKeys(mapExpression)

Creates an expression that returns the keys of a map.

While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.

**Signature:**

```typescript
export declare function mapKeys(mapExpression: Expression): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the map to get the keys of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the keys of the map.

### Example

```typescript
// Get the keys of the map expression
mapKeys(map({"city": "San Francisco"}));

```

### mapSet(mapExpression, key, value, moreKeyValues)

Creates an expression that returns a new map with the specified entries added or updated.

This only performs shallow updates to the map. Setting a value to `null` will retain the key with a `null` value. To remove a key entirely, use `mapRemove`.

**Signature:**

```typescript
export declare function mapSet(
  mapExpression: Expression,
  key: string | Expression,
  value: unknown,
  ...moreKeyValues: unknown[]
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the map. |
| key | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The key to set. Must be a string or a constant string expression. |
| value | unknown | The value to set. |
| moreKeyValues | unknown\[\] | Additional key-value pairs to set. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the map with the entries set.

### Example

```typescript
// Set the 'city' to "San Francisco"
mapSet(map({"state": "California"}), "city", "San Francisco");

```

### mapValues(mapExpression)

Creates an expression that returns the values of a map.

While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.

**Signature:**

```typescript
export declare function mapValues(
  mapExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the map to get the values of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the values of the map.

### Example

```typescript
// Get the values of the map expression
mapValues(map({"city": "San Francisco"}));

```

## function(mapField, ...)

### mapEntries(mapField)

Creates an expression that returns the entries of a map as an array of maps, where each map contains a `"k"` property for the key and a `"v"` property for the value. For example: `[{ k: "key1", v: "value1" }, ...]`.

While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.

**Signature:**

```typescript
export declare function mapEntries(mapField: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapField | string | The map field to get the entries of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the entries of the map.

### Example

```typescript
// Get the entries of the 'address' map field
mapEntries("address");

```

### mapKeys(mapField)

Creates an expression that returns the keys of a map.

While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.

**Signature:**

```typescript
export declare function mapKeys(mapField: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapField | string | The map field to get the keys of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the keys of the map.

### Example

```typescript
// Get the keys of the 'address' map field
mapKeys("address");

```

### mapMerge(mapField, secondMap, otherMaps)

Creates an expression that merges multiple map values.

**Signature:**

```typescript
export declare function mapMerge(
  mapField: string,
  secondMap: Record<string, unknown> | Expression,
  ...otherMaps: Array<Record<string, unknown> | Expression>
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapField | string | Name of a field containing a map value that will be merged. |
| secondMap | Record\<string, unknown\> \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | A required second map to merge. Represented as a literal or an expression that returns a map. |
| otherMaps | Array\<Record\<string, unknown\> \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)\> | Optional additional maps to merge. Each map is represented as a literal or an expression that returns a map. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

### Example

```typescript
// 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 }, conditional(field('isAdmin'), { admin: true}, {})

```

### mapRemove(mapField, key)

Creates an expression that removes a key from the map at the specified field name.

**Signature:**

```typescript
export declare function mapRemove(
  mapField: string,
  key: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapField | string | The name of a field containing a map value. |
| key | string | The name of the key to remove from the input map. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

### Example

```typescript
// Removes the key 'city' field from the map in the address field of the input document.
mapRemove('address', 'city');

```

### mapRemove(mapField, keyExpr)

Creates an expression that removes a key from the map at the specified field name.

**Signature:**

```typescript
export declare function mapRemove(
  mapField: string,
  keyExpr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapField | string | The name of a field containing a map value. |
| keyExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression that produces the name of the key to remove from the input map. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

### Example

```typescript
// Removes the key 'city' field from the map in the address field of the input document.
mapRemove('address', constant('city'));

```

### mapSet(mapField, key, value, moreKeyValues)

Creates an expression that returns a new map with the specified entries added or updated.

This only performs shallow updates to the map. Setting a value to `null` will retain the key with a `null` value. To remove a key entirely, use `mapRemove`.

**Signature:**

```typescript
export declare function mapSet(
  mapField: string,
  key: string | Expression,
  value: unknown,
  ...moreKeyValues: unknown[]
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapField | string | The map field to set entries in. |
| key | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The key to set. Must be a string or a constant string expression. |
| value | unknown | The value to set. |
| moreKeyValues | unknown\[\] | Additional key-value pairs to set. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the map with the entries set.

### Example

```typescript
// Set the 'city' to 'San Francisco' in the 'address' map field
mapSet("address", "city", "San Francisco");

```

### mapValues(mapField)

Creates an expression that returns the values of a map.

While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.

**Signature:**

```typescript
export declare function mapValues(mapField: string): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| mapField | string | The map field to get the values of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the values of the map.

### Example

```typescript
// Get the values of the 'address' map field
mapValues("address");

```

## function(name, ...)

### field(name)

Creates a [Field](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.field.md.txt#field_class) 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").

**Signature:**

```typescript
export declare function field(name: string): Field;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| name | string | The path to the field. |

**Returns:**

[Field](https://firebase.google.com/docs/reference/js/firestore_pipelines.field.md.txt#field_class)

A new [Field](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.field.md.txt#field_class) instance representing the specified field.

### Example

```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");

```

### variable(name)

Creates an expression that retrieves the value of a variable bound via `define()`.

**Signature:**

```typescript
export declare function variable(name: string): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| name | string | The name of the variable to retrieve. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

An [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the variable's value.

### Example

```typescript
db.pipeline().collection("products")
  .define(
    field("price").multiply(0.9).as("discountedPrice"),
    field("stock").add(10).as("newStock")
  )
  .where(variable("discountedPrice").lessThan(100))
  .select(field("name"), variable("newStock"));

```

## function(options, ...)

### execute(options)

Executes a pipeline and returns a Promise that represents 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 [PipelineSnapshot](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesnapshot.md.txt#pipelinesnapshot_class) that contains a list of [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) objects. Each [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#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_lite_pipelines.pipelineresult#pipelineresult_class) represents a single document.
- If there is an aggregation, only a single \[PipelineResult\](./firestore_lite_pipelines.pipelineresult#pipelineresult_class) is returned, representing the aggregated results over the entire dataset.
- If there is an aggregation stage with grouping, each \[PipelineResult\](./firestore_lite_pipelines.pipelineresult#pipelineresult_class) represents a distinct group and its associated aggregated values.

**Signature:**

```typescript
export declare function execute(
  options: PipelineExecuteOptions
): Promise<PipelineSnapshot>;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| options | [PipelineExecuteOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipelineexecuteoptions.md.txt#pipelineexecuteoptions_interface) | Specifies the pipeline to execute and other execution options. |

**Returns:**

Promise\<[PipelineSnapshot](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipelinesnapshot.md.txt#pipelinesnapshot_class)\>

A Promise representing the asynchronous pipeline execution.

### Example

```typescript
const snapshot: PipelineSnapshot = await execute({
  pipeline: firestore.pipeline().collection("books")
    .where(lessThan(field("rating"), 2))
    .delete(),
  atomic: true
});

const results: PipelineResult[] = snapshot.results;

```

### subcollection(options)

Creates a new Pipeline targeted at a subcollection relative to the current document context. This creates a pipeline without a database instance, suitable for embedding as a subquery. If executed directly, this pipeline will fail.

**Signature:**

```typescript
export declare function subcollection(
  options: SubcollectionStageOptions
): Pipeline;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| options | [SubcollectionStageOptions](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#subcollectionstageoptions) | Options defining how this SubcollectionStage is evaluated. |

**Returns:**

[Pipeline](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipeline.md.txt#pipeline_class)

## function(path, ...)

### field(path)

Creates a [Field](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.field.md.txt#field_class) instance representing the field at the given path.

**Signature:**

```typescript
export declare function field(path: FieldPath): Field;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| path | [FieldPath](https://firebase.google.com/docs/reference/js/firestore.fieldpath.md.txt#fieldpath_class) | A FieldPath specifying the field. |

**Returns:**

[Field](https://firebase.google.com/docs/reference/js/firestore_pipelines.field.md.txt#field_class)

A new [Field](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.field.md.txt#field_class) instance representing the specified field.

### subcollection(path)

Creates a new Pipeline targeted at a subcollection relative to the current document context. This creates a pipeline without a database instance, suitable for embedding as a subquery. If executed directly, this pipeline will fail.

**Signature:**

```typescript
export declare function subcollection(path: string): Pipeline;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| path | string | The relative path to the subcollection. |

**Returns:**

[Pipeline](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipeline.md.txt#pipeline_class)

## function(pipeline, ...)

### execute(pipeline)

Executes a pipeline and returns a Promise that represents 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 [PipelineSnapshot](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesnapshot.md.txt#pipelinesnapshot_class) that contains a list of [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#pipelineresult_class) objects. Each [PipelineResult](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelineresult.md.txt#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_lite_pipelines.pipelineresult#pipelineresult_class) represents a single document.
- If there is an aggregation, only a single \[PipelineResult\](./firestore_lite_pipelines.pipelineresult#pipelineresult_class) is returned, representing the aggregated results over the entire dataset.
- If there is an aggregation stage with grouping, each \[PipelineResult\](./firestore_lite_pipelines.pipelineresult#pipelineresult_class) represents a distinct group and its associated aggregated values.

**Signature:**

```typescript
export declare function execute(pipeline: Pipeline): Promise<PipelineSnapshot>;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| pipeline | [Pipeline](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipeline.md.txt#pipeline_class) | The pipeline to execute. |

**Returns:**

Promise\<[PipelineSnapshot](https://firebase.google.com/docs/reference/js/firestore_pipelines.pipelinesnapshot.md.txt#pipelinesnapshot_class)\>

A Promise representing the asynchronous pipeline execution.

### Example

```typescript
const snapshot: PipelineSnapshot = await execute(firestore.pipeline().collection("books")
    .where(greaterThan(field("rating"), 4.5))
    .select("title", "author", "rating"));

const results: PipelineResult[] = snapshot.results;

```

## function(rquery, ...)

### documentMatches(rquery)

Perform a full-text search on all indexed search fields in the document.

This Expression can only be used within a `search` stage.

**Signature:**

```typescript
export declare function documentMatches(
  rquery: string | Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| rquery | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Define the search query using the search domain-specific language (DSL). |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

### Example

```typescript
db.pipeline().collection('restaurants').search({
  query: documentMatches('waffles OR pancakes')
})

```

## function(stringExpression, ...)

### charLength(stringExpression)

Creates an expression that calculates the character length of a string expression in UTF-8.

**Signature:**

```typescript
export declare function charLength(
  stringExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to calculate the length of. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the length of the string.

### Example

```typescript
// Get the character length of the 'name' field in UTF-8.
charLength(field("name"));

```

### endsWith(stringExpression, suffix)

Creates an expression that checks if a string expression ends with a given postfix.

**Signature:**

```typescript
export declare function endsWith(
  stringExpression: Expression,
  suffix: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check. |
| suffix | string | The postfix to check for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'ends with' comparison.

### Example

```typescript
// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr."
endsWith(field("fullName"), "Jr.");

```

### endsWith(stringExpression, suffix)

Creates an expression that checks if a string expression ends with a given postfix.

**Signature:**

```typescript
export declare function endsWith(
  stringExpression: Expression,
  suffix: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check. |
| suffix | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The postfix to check for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'ends with' comparison.

### Example

```typescript
// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr."
endsWith(field("fullName"), constant("Jr."));

```

### like(stringExpression, pattern)

Creates an expression that performs a case-sensitive wildcard string comparison.

**Signature:**

```typescript
export declare function like(
  stringExpression: Expression,
  pattern: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_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. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'like' comparison.

### Example

```typescript
// Check if the 'title' field contains the string "guide"
like(field("title"), "%guide%");

```

### like(stringExpression, pattern)

Creates an expression that performs a case-sensitive wildcard string comparison.

**Signature:**

```typescript
export declare function like(
  stringExpression: Expression,
  pattern: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to perform the comparison on. |
| pattern | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The pattern to search for. You can use "%" as a wildcard character. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'like' comparison.

### Example

```typescript
// Check if the 'title' field contains the string "guide"
like(field("title"), field("pattern"));

```

### regexContains(stringExpression, pattern)

Creates an expression that checks if a string expression contains a specified regular expression as a substring.

**Signature:**

```typescript
export declare function regexContains(
  stringExpression: Expression,
  pattern: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to perform the comparison on. |
| pattern | string | The regular expression to use for the search. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'contains' comparison.

### Example

```typescript
// Check if the 'description' field contains "example" (case-insensitive)
regexContains(field("description"), "(?i)example");

```

### regexContains(stringExpression, pattern)

Creates an expression that checks if a string expression contains a specified regular expression as a substring.

**Signature:**

```typescript
export declare function regexContains(
  stringExpression: Expression,
  pattern: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to perform the comparison on. |
| pattern | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The regular expression to use for the search. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'contains' comparison.

### Example

```typescript
// Check if the 'description' field contains "example" (case-insensitive)
regexContains(field("description"), field("pattern"));

```

### regexFind(stringExpression, pattern)

Creates an expression that returns the first substring of a string expression that matches a specified regular expression.

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

**Signature:**

```typescript
export declare function regexFind(
  stringExpression: Expression,
  pattern: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to search. |
| pattern | string | The regular expression to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the regular expression find function.

### Example

```typescript
// Extract the domain from a lower-cased email address
regexFind(field("email"), "@[A-Za-z0-9.-]+");

```

### regexFind(stringExpression, pattern)

Creates an expression that returns the first substring of a string expression that matches a specified regular expression.

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

**Signature:**

```typescript
export declare function regexFind(
  stringExpression: Expression,
  pattern: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to search. |
| pattern | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The regular expression to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the regular expression find function.

### Example

```typescript
// Extract a substring based on a dynamic pattern field
regexFind(field("email"), field("pattern"));

```

### regexFindAll(stringExpression, pattern)

Creates an expression that evaluates to a list of all substrings in a string expression that match a specified regular expression.

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

**Signature:**

```typescript
export declare function regexFindAll(
  stringExpression: Expression,
  pattern: string
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to search. |
| pattern | string | The regular expression to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.functionexpression.md.txt#functionexpression_class) that evaluates to an array of matched substrings.

### Example

```typescript
// Extract all mentions from a lower-cased comment
regexFindAll(field("comment"), "@[A-Za-z0-9_]+");

```

### regexFindAll(stringExpression, pattern)

Creates an expression that evaluates to a list of all substrings in a string expression that match a specified regular expression.

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

**Signature:**

```typescript
export declare function regexFindAll(
  stringExpression: Expression,
  pattern: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to search. |
| pattern | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The regular expression to search for. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.functionexpression.md.txt#functionexpression_class) that evaluates to an array of matched substrings.

### Example

```typescript
// Extract all matches based on a dynamic pattern expression
regexFindAll(field("comment"), field("pattern"));

```

### regexMatch(stringExpression, pattern)

Creates an expression that checks if a string expression matches a specified regular expression.

**Signature:**

```typescript
export declare function regexMatch(
  stringExpression: Expression,
  pattern: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to match against. |
| pattern | string | The regular expression to use for the match. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the regular expression match.

### Example

```typescript
// Check if the 'email' field matches a valid email pattern
regexMatch(field("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}");

```

### regexMatch(stringExpression, pattern)

Creates an expression that checks if a string expression matches a specified regular expression.

**Signature:**

```typescript
export declare function regexMatch(
  stringExpression: Expression,
  pattern: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to match against. |
| pattern | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The regular expression to use for the match. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the regular expression match.

### Example

```typescript
// Check if the 'email' field matches a valid email pattern
regexMatch(field("email"), field("pattern"));

```

### reverse(stringExpression)

Creates an expression that reverses a string.

**Signature:**

```typescript
export declare function reverse(
  stringExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a string value, which will be reversed. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the reversed string.

### Example

```typescript
// Reverse the value of the 'myString' field.
reverse(field("myString"));

```

### startsWith(stringExpression, prefix)

Creates an expression that checks if a string expression starts with a given prefix.

**Signature:**

```typescript
export declare function startsWith(
  stringExpression: Expression,
  prefix: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check. |
| prefix | string | The prefix to check for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'starts with' comparison.

### Example

```typescript
// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr."
startsWith(field("fullName"), "Mr.");

```

### startsWith(stringExpression, prefix)

Creates an expression that checks if a string expression starts with a given prefix.

**Signature:**

```typescript
export declare function startsWith(
  stringExpression: Expression,
  prefix: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check. |
| prefix | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The prefix to check for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'starts with' comparison.

### Example

```typescript
// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr."
startsWith(field("fullName"), field("prefix"));

```

### stringContains(stringExpression, substring)

Creates an expression that checks if a string expression contains a specified substring.

**Signature:**

```typescript
export declare function stringContains(
  stringExpression: Expression,
  substring: string
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to perform the comparison on. |
| substring | string | The substring to search for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'contains' comparison.

### Example

```typescript
// Check if the 'description' field contains "example".
stringContains(field("description"), "example");

```

### stringContains(stringExpression, substring)

Creates an expression that checks if a string expression contains a substring specified by another expression.

**Signature:**

```typescript
export declare function stringContains(
  stringExpression: Expression,
  substring: Expression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to perform the comparison on. |
| substring | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the substring to search for. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'contains' comparison.

### Example

```typescript
// Check if the 'description' field contains the value of the 'keyword' field.
stringContains(field("description"), field("keyword"));

```

### stringReverse(stringExpression)

Creates an expression that reverses a string.

**Signature:**

```typescript
export declare function stringReverse(
  stringExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluating to a string value, which will be reversed. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the reversed string.

### Example

```typescript
// Reverse the value of the 'myString' field.
stringReverse(field("myString"));

```

### toLower(stringExpression)

Creates an expression that converts a string expression to lowercase.

**Signature:**

```typescript
export declare function toLower(
  stringExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to convert to lowercase. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the lowercase string.

### Example

```typescript
// Convert the 'name' field to lowercase
toLower(field("name"));

```

### toUpper(stringExpression)

Creates an expression that converts a string expression to uppercase.

**Signature:**

```typescript
export declare function toUpper(
  stringExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string to convert to uppercase. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the uppercase string.

### Example

```typescript
// Convert the 'title' field to uppercase
toUpper(field("title"));

```

### trim(stringExpression, valueToTrim)

Creates an expression that removes leading and trailing characters from a string or byte array expression.

**Signature:**

```typescript
export declare function trim(
  stringExpression: Expression,
  valueToTrim?: string | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| stringExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the string or byte array to trim. |
| valueToTrim | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Optional This parameter is treated as a set of characters or bytes that will be trimmed from the input. If not specified, then whitespace will be trimmed. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the trimmed string or byte array.

### Example

```typescript
// Trim whitespace from the 'userInput' field
trim(field("userInput"));

// Trim quotes from the 'userInput' field
trim(field("userInput"), '"');

```

## function(timestamp, ...)

### timestampAdd(timestamp, unit, amount)

Creates an expression that adds a specified amount of time to a timestamp.

**Signature:**

```typescript
export declare function timestampAdd(
  timestamp: Expression,
  unit: Expression,
  amount: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| timestamp | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the timestamp. |
| unit | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. |
| amount | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression evaluates to amount of the unit. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the resulting timestamp.

### Example

```typescript
// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field.
timestampAdd(field("timestamp"), field("unit"), field("amount"));

```

### timestampAdd(timestamp, unit, amount)

Creates an expression that adds a specified amount of time to a timestamp.

**Signature:**

```typescript
export declare function timestampAdd(
  timestamp: Expression,
  unit: TimeUnit,
  amount: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| timestamp | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the timestamp. |
| unit | [TimeUnit](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timeunit) | The unit of time to add (e.g., "day", "hour"). |
| amount | number | The amount of time to add. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the resulting timestamp.

### Example

```typescript
// Add 1 day to the 'timestamp' field.
timestampAdd(field("timestamp"), "day", 1);

```

### timestampSubtract(timestamp, unit, amount)

Creates an expression that subtracts a specified amount of time from a timestamp.

**Signature:**

```typescript
export declare function timestampSubtract(
  timestamp: Expression,
  unit: Expression,
  amount: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| timestamp | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the timestamp. |
| unit | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. |
| amount | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression evaluates to amount of the unit. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the resulting timestamp.

### Example

```typescript
// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field.
timestampSubtract(field("timestamp"), field("unit"), field("amount"));

```

### timestampSubtract(timestamp, unit, amount)

Creates an expression that subtracts a specified amount of time from a timestamp.

**Signature:**

```typescript
export declare function timestampSubtract(
  timestamp: Expression,
  unit: TimeUnit,
  amount: number
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| timestamp | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the timestamp. |
| unit | [TimeUnit](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timeunit) | The unit of time to subtract (e.g., "day", "hour"). |
| amount | number | The amount of time to subtract. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the resulting timestamp.

### Example

```typescript
// Subtract 1 day from the 'timestamp' field.
timestampSubtract(field("timestamp"), "day", 1);

```

## function(timestampExpression, ...)

### timestampExtract(timestampExpression, part, timezone)

Creates an expression that extracts a specified part from a timestamp.

**Signature:**

```typescript
export declare function timestampExtract(
  timestampExpression: Expression,
  part: TimePart,
  timezone?: string | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| timestampExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression evaluating to the timestamp. |
| part | [TimePart](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timepart) | The part to extract from the timestamp (e.g., "year", "month", "day"). |
| timezone | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The timezone to use for extraction. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1." |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the extracted part as an integer.

### Example

```typescript
// Extract the year from the timestamp returned by the expression.
timestampExtract(field('createdAt'), 'year')

```

### timestampExtract(timestampExpression, part, timezone)

Creates an expression that extracts a specified part from a timestamp.

**Signature:**

```typescript
export declare function timestampExtract(
  timestampExpression: Expression,
  part: Expression,
  timezone?: string | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| timestampExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression evaluating to the timestamp. |
| part | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression evaluating to the part to extract. |
| timezone | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The timezone to use for extraction. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1." |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the extracted part as an integer.

### Example

```typescript
// Extract the part specified by the field 'part' from the timestamp.
timestampExtract(field('createdAt'), field('part'))

```

### timestampTruncate(timestampExpression, granularity, timezone)

Creates an expression that truncates a timestamp to a specified granularity.

**Signature:**

```typescript
export declare function timestampTruncate(
  timestampExpression: Expression,
  granularity: TimeGranularity,
  timezone?: string | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| timestampExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Truncate the timestamp value that is returned by this expression. |
| granularity | [TimeGranularity](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#timegranularity) | The granularity to truncate to. |
| timezone | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the truncated timestamp.

### Example

```typescript
// Truncate the 'createdAt' timestamp to the beginning of the day.
timestampTruncate(field('createdAt'), 'day')

```

### timestampTruncate(timestampExpression, granularity, timezone)

Creates an expression that truncates a timestamp to a specified granularity.

**Signature:**

```typescript
export declare function timestampTruncate(
  timestampExpression: Expression,
  granularity: Expression,
  timezone?: string | Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| timestampExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | Truncate the timestamp value that is returned by this expression. |
| granularity | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The granularity to truncate to. |
| timezone | string \| [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new `Expression` representing the truncated timestamp.

### Example

```typescript
// Truncate the 'createdAt' timestamp to the granularity specified in the field 'granularity'.
timestampTruncate(field('createdAt'), field('granularity'))

```

## function(tryExpr, ...)

### ifError(tryExpr, catchExpr)

Creates an expression that returns the `catch` argument if there is an error, else return the result of the `try` argument evaluation.

This overload is useful when a BooleanExpression is required.

**Signature:**

```typescript
export declare function ifError(
  tryExpr: BooleanExpression,
  catchExpr: BooleanExpression
): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| tryExpr | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The try expression. |
| catchExpr | [BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class) | The catch expression that will be evaluated and returned if the tryExpr produces an error. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'ifError' operation.

### Example

```typescript
// Create an expression that protects against a divide by zero error
// but always returns a boolean expression.
ifError(constant(50).divide(field('length')).greaterThan(1), constant(false));

```

### ifError(tryExpr, catchExpr)

Creates an expression that returns the `catch` argument if there is an error, else return the result of the `try` argument evaluation.

**Signature:**

```typescript
export declare function ifError(
  tryExpr: Expression,
  catchExpr: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| tryExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The try expression. |
| catchExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The catch expression that will be evaluated and returned if the tryExpr produces an error. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'ifError' operation.

### Example

```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").arrayGet(0), field("title"));

```

### ifError(tryExpr, catchValue)

Creates an expression that returns the `catch` argument if there is an error, else return the result of the `try` argument evaluation.

**Signature:**

```typescript
export declare function ifError(
  tryExpr: Expression,
  catchValue: unknown
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| tryExpr | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The try expression. |
| catchValue | unknown | The value that will be returned if the tryExpr produces an error. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'ifError' operation.

### Example

```typescript
// Returns the first item in the title field arrays, or returns
// "Default Title"
ifError(field("title").arrayGet(0), "Default Title");

```

## function(value, ...)

### constant(value, options)

Creates a `Constant` instance for a number value.

**Signature:**

```typescript
export declare function constant(
  value: number,
  options?: {
    preferIntegers?: boolean;
  }
): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | number | The number value. |
| options | { preferIntegers?: boolean; } |   |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new `Constant` instance.

### constant(value)

Creates a `Constant` instance for a VectorValue value.

**Signature:**

```typescript
export declare function constant(value: VectorValue): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | [VectorValue](https://firebase.google.com/docs/reference/js/firestore.vectorvalue.md.txt#vectorvalue_class) | The VectorValue value. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new `Constant` instance.

### constant(value)

Creates a `Constant` instance for a string value.

**Signature:**

```typescript
export declare function constant(value: string): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | string | The string value. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new `Constant` instance.

### constant(value)

Creates a `BooleanExpression` instance for a boolean value.

**Signature:**

```typescript
export declare function constant(value: boolean): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | boolean | The boolean value. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new `Constant` instance.

### constant(value)

Creates a `Constant` instance for a null value.

**Signature:**

```typescript
export declare function constant(value: null): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | null | The null value. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new `Constant` instance.

### constant(value)

Creates a `Constant` instance for a GeoPoint value.

**Signature:**

```typescript
export declare function constant(value: GeoPoint): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | [GeoPoint](https://firebase.google.com/docs/reference/js/firestore.geopoint.md.txt#geopoint_class) | The GeoPoint value. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new `Constant` instance.

### constant(value)

Creates a `Constant` instance for a Timestamp value.

**Signature:**

```typescript
export declare function constant(value: Timestamp): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | [Timestamp](https://firebase.google.com/docs/reference/js/firestore.timestamp.md.txt#timestamp_class) | The Timestamp value. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new `Constant` instance.

### constant(value)

Creates a `Constant` instance for a Date value.

**Signature:**

```typescript
export declare function constant(value: Date): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | Date | The Date value. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new `Constant` instance.

### constant(value)

Creates a `Constant` instance for a Bytes value.

**Signature:**

```typescript
export declare function constant(value: Bytes): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | [Bytes](https://firebase.google.com/docs/reference/js/firestore.bytes.md.txt#bytes_class) | The Bytes value. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new `Constant` instance.

### constant(value)

Creates a `Constant` instance for a DocumentReference value.

**Signature:**

```typescript
export declare function constant(value: DocumentReference): Expression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | [DocumentReference](https://firebase.google.com/docs/reference/js/firestore.documentreference.md.txt#documentreference_class) | The DocumentReference value. |

**Returns:**

[Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class)

A new `Constant` instance.

### exists(value)

Creates an expression that checks if a field exists.

**Signature:**

```typescript
export declare function exists(value: Expression): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | An expression evaluates to the name of the field to check. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'exists' check.

### Example

```typescript
// Check if the document has a field named "phoneNumber"
exists(field("phoneNumber"));

```

### isAbsent(value)

Creates an expression that returns `true` if a value is absent. Otherwise, returns `false` even if the value is `null`.

**Signature:**

```typescript
export declare function isAbsent(value: Expression): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'isAbsent' check.

### Example

```typescript
// Check if the field `value` is absent.
isAbsent(field("value"));

```

### isError(value)

Creates an expression that checks if a given expression produces an error.

**Signature:**

```typescript
export declare function isError(value: Expression): BooleanExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| value | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression to check. |

**Returns:**

[BooleanExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.booleanexpression.md.txt#booleanexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the 'isError' check.

### Example

```typescript
// Check if the result of a calculation is an error
isError(field("title").arrayContains(1));

```

## function(vectorExpression, ...)

### cosineDistance(vectorExpression, vector)

Calculates the Cosine distance between a vector expression and a vector literal.

**Signature:**

```typescript
export declare function cosineDistance(
  vectorExpression: Expression,
  vector: number[] | VectorValue
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| vectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first vector (represented as an `Expression`) to compare against. |
| vector | number\[\] \| [VectorValue](https://firebase.google.com/docs/reference/js/firestore.vectorvalue.md.txt#vectorvalue_class) | The other vector (as an array of doubles or VectorValue) to compare against. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the cosine distance between the two vectors.

### Example

```typescript
// Calculate the cosine distance between the 'location' field and a target location
cosineDistance(field("location"), [37.7749, -122.4194]);

```

### cosineDistance(vectorExpression, otherVectorExpression)

Calculates the Cosine distance between two vector expressions.

**Signature:**

```typescript
export declare function cosineDistance(
  vectorExpression: Expression,
  otherVectorExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| vectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first vector (represented as an `Expression`) to compare against. |
| otherVectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The other vector (represented as an `Expression`) to compare against. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the cosine distance between the two vectors.

### Example

```typescript
// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field
cosineDistance(field("userVector"), field("itemVector"));

```

### dotProduct(vectorExpression, vector)

Calculates the dot product between a vector expression and a double array.

**Signature:**

```typescript
export declare function dotProduct(
  vectorExpression: Expression,
  vector: number[] | VectorValue
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| vectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first vector (represented as an `Expression`) to calculate with. |
| vector | number\[\] \| [VectorValue](https://firebase.google.com/docs/reference/js/firestore.vectorvalue.md.txt#vectorvalue_class) | The other vector (as an array of doubles or VectorValue) to calculate with. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the dot product between the two vectors.

### Example

```typescript
// Calculate the dot product between a feature vector and a target vector
dotProduct(field("features"), [0.5, 0.8, 0.2]);

```

### dotProduct(vectorExpression, otherVectorExpression)

Calculates the dot product between two vector expressions.

**Signature:**

```typescript
export declare function dotProduct(
  vectorExpression: Expression,
  otherVectorExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| vectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first vector (represented as an `Expression`) to calculate with. |
| otherVectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The other vector (represented as an `Expression`) to calculate with. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the dot product between the two vectors.

### Example

```typescript
// Calculate the dot product between two document vectors: 'docVector1' and 'docVector2'
dotProduct(field("docVector1"), field("docVector2"));

```

### euclideanDistance(vectorExpression, vector)

Calculates the Euclidean distance between a vector expression and a double array.

**Signature:**

```typescript
export declare function euclideanDistance(
  vectorExpression: Expression,
  vector: number[] | VectorValue
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| vectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first vector (represented as an `Expression`) to compare against. |
| vector | number\[\] \| [VectorValue](https://firebase.google.com/docs/reference/js/firestore.vectorvalue.md.txt#vectorvalue_class) | The other vector (as an array of doubles or VectorValue) to compare against. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the Euclidean distance between the two vectors.

### Example

```typescript
// Calculate the Euclidean distance between the 'location' field and a target location

euclideanDistance(field("location"), [37.7749, -122.4194]);

```

### euclideanDistance(vectorExpression, otherVectorExpression)

Calculates the Euclidean distance between two vector expressions.

**Signature:**

```typescript
export declare function euclideanDistance(
  vectorExpression: Expression,
  otherVectorExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| vectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The first vector (represented as an `Expression`) to compare against. |
| otherVectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The other vector (represented as an `Expression`) to compare against. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the Euclidean distance between the two vectors.

### Example

```typescript
// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB'
euclideanDistance(field("pointA"), field("pointB"));

```

### vectorLength(vectorExpression)

Creates an expression that calculates the length of a Firestore Vector.

**Signature:**

```typescript
export declare function vectorLength(
  vectorExpression: Expression
): FunctionExpression;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| vectorExpression | [Expression](https://firebase.google.com/docs/reference/js/firestore_pipelines.expression.md.txt#expression_class) | The expression representing the Firestore Vector. |

**Returns:**

[FunctionExpression](https://firebase.google.com/docs/reference/js/firestore_pipelines.functionexpression.md.txt#functionexpression_class)

A new [Expression](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.expression.md.txt#expression_class) representing the length of the array.

### Example

```typescript
// Get the vector length (dimension) of the field 'embedding'.
vectorLength(field("embedding"));

```

## AddFieldsStageOptions

Options defining how an AddFieldsStage is evaluated. See [Pipeline.addFields()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineaddfields).

**Signature:**

```typescript
export declare type AddFieldsStageOptions = StageOptions & {
  fields: Selectable[];
};
```

## AddWindowFieldsStageOptions

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Options defining how an AddWindowFieldsStage is evaluated. See [Pipeline.addWindowFields()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineaddwindowfields).

Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes

**Signature:**

```typescript
export declare type AddWindowFieldsStageOptions = StageOptions & {
  window: WindowSpec;
  fields: Array<AliasedAggregate | AliasedWindowFunction>;
};
```

## AggregateStageOptions

Options defining how an AggregateStage is evaluated. See [Pipeline.aggregate()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineaggregate).

**Signature:**

```typescript
export declare type AggregateStageOptions = StageOptions & {
  accumulators: AliasedAggregate[];
  groups?: Array<string | Selectable>;
};
```

## CollectionGroupStageOptions

Defines the configuration options for a CollectionGroupStage within a pipeline. This type extends [StageOptions](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.md.txt#stageoptions) and provides specific settings for how a collection group is identified and processed during pipeline execution.

See [PipelineSource.collectionGroup()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcecollectiongroup) to create a collection group stage.

**Signature:**

```typescript
export declare type CollectionGroupStageOptions = StageOptions & {
  collectionId: string;
  forceIndex?: string;
};
```

## CollectionStageOptions

Options defining how a CollectionStage is evaluated. See [PipelineSource.collection()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcecollection).

**Signature:**

```typescript
export declare type CollectionStageOptions = StageOptions & {
  collection: string | CollectionReference;
  forceIndex?: string;
};
```

## DatabaseStageOptions

Options defining how a DatabaseStage is evaluated. See [PipelineSource.database()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcedatabase).

**Signature:**

```typescript
export declare type DatabaseStageOptions = StageOptions & {};
```

## DefineStageOptions

Options defining how a DefineStage is evaluated. See [Pipeline.define()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinedefine).

**Signature:**

```typescript
export declare type DefineStageOptions = StageOptions & {
  variables: AliasedExpression[];
};
```

## DeleteStageOptions

Options for defining a `delete` stage in a [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipeline_class).

**Signature:**

```typescript
export declare type DeleteStageOptions = StageOptions;
```

## DistinctStageOptions

Options defining how a DistinctStage is evaluated. See [Pipeline.distinct()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinedistinct).

**Signature:**

```typescript
export declare type DistinctStageOptions = StageOptions & {
  groups: Array<string | Selectable>;
};
```

## DocumentsStageOptions

Options defining how a DocumentsStage is evaluated. See [PipelineSource.documents()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourcedocuments).

**Signature:**

```typescript
export declare type DocumentsStageOptions = StageOptions & {
  docs: Array<string | DocumentReference>;
};
```

## ExpressionType

An enumeration of the different types of expressions.

**Signature:**

```typescript
export declare type ExpressionType =
  | 'Field'
  | 'Constant'
  | 'Function'
  | 'AggregateFunction'
  | 'WindowFunction'
  | 'ListOfExpressions'
  | 'AliasedExpression'
  | 'Variable'
  | 'PipelineValue';
```

## FindNearestStageOptions

Options defining how a FindNearestStage is evaluated. See [Pipeline.findNearest()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinefindnearest).

**Signature:**

```typescript
export declare type FindNearestStageOptions = StageOptions & {
  field: Field | string;
  vectorValue: VectorValue | number[];
  distanceMeasure: 'euclidean' | 'cosine' | 'dot_product';
  limit?: number;
  distanceField?: string;
};
```

## InsertStageOptions

Options for defining an `insert` stage in a [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipeline_class).

The target document path for each inserted document is determined by the combination of `collection` and `documentIdExpression`: - \*\*Neither set:\*\* Inserts each document at its existing `__name__` path. If an input document does not have a `__name__` field (for example, when inputs come from [PipelineSource.literals()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourceliterals) without `__name__` or after `.removeFields('__name__')`), the operation fails. - \*\*`collection` only:\*\* Inserts into `collection`. If the input document has a `__name__` field, its document ID is reused; otherwise a new document ID is auto-generated (for example, when inputs come from [PipelineSource.literals()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourceliterals) or after `.removeFields('__name__')`). - \*\*`documentIdExpression` only:\*\* Inserts into the input document's parent collection using the evaluated document ID. Requires each input document to have a `__name__` field; otherwise the operation fails. - \*\*Both `collection` and `documentIdExpression` set:\*\* Inserts into `collection` using the evaluated document ID.

The operation fails if a document already exists at any target path. In particular, setting neither `collection` nor `documentIdExpression` fails for documents read from the database, because they already exist at their `__name__` path.

**Signature:**

```typescript
export declare type InsertStageOptions = StageOptions & {
  collection?: string | CollectionReference;
  documentIdExpression?: string | Expression;
};
```

## LimitStageOptions

Options defining how a LimitStage is evaluated. See [Pipeline.limit()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinelimit).

**Signature:**

```typescript
export declare type LimitStageOptions = StageOptions & {
  limit: number;
};
```

## LiteralsStageOptions

Options for defining a `literals` stage on a [PipelineSource](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesource_class).

**Signature:**

```typescript
export declare type LiteralsStageOptions = StageOptions & {
  documents: Array<Record<string, unknown>>;
};
```

## OffsetStageOptions

Options defining how an OffsetStage is evaluated. See [Pipeline.offset()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineoffset).

**Signature:**

```typescript
export declare type OffsetStageOptions = StageOptions & {
  offset: number;
};
```

## OneOf

Utility type to create an type that only allows one property of the Type param T to be set.

**Signature:**

```typescript
export declare type OneOf<T> = {
  [K in keyof T]: Pick<T, K> & {
    [P in Exclude<keyof T, K>]?: undefined;
  };
}[keyof T];
```

### Example

```typescript
type XorY = OneOf<{ x: unknown, y: unknown }>
let a = { x: "foo" }           // OK
let b = { y: "foo" }           // OK
let c = { a: "foo", y: "foo" } // Not OK

```

## RemoveFieldsStageOptions

Options defining how a RemoveFieldsStage is evaluated. See [Pipeline.removeFields()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineremovefields).

**Signature:**

```typescript
export declare type RemoveFieldsStageOptions = StageOptions & {
  fields: Array<Field | string>;
};
```

## ReplaceWithStageOptions

Options defining how a ReplaceWithStage is evaluated. See [Pipeline.replaceWith()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinereplacewith).

**Signature:**

```typescript
export declare type ReplaceWithStageOptions = StageOptions & {
  map: Expression | string;
};
```

## SampleStageOptions

Defines the options for evaluating a sample stage within a pipeline. This type combines common [StageOptions](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.md.txt#stageoptions) with a specific configuration where only one of the defined sampling methods can be applied.

See [Pipeline.sample()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinesample) to create a sample stage..

**Signature:**

```typescript
export declare type SampleStageOptions = StageOptions &
  OneOf<{
    percentage: number;
    documents: number;
  }>;
```

## SearchStageOptions

Options defining how a search stage is evaluated. See [Pipeline.search()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinesearch).

**Signature:**

```typescript
export declare type SearchStageOptions = StageOptions & {
  query: BooleanExpression | string;
  languageCode?: string;
  retrievalDepth?: number;
  sort?: Ordering | Ordering[];
  offset?: number;
  limit?: number;
  addFields?: Selectable[];
};
```

## SelectStageOptions

Options defining how a SelectStage is evaluated. See [Pipeline.select()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineselect).

**Signature:**

```typescript
export declare type SelectStageOptions = StageOptions & {
  selections: Array<Selectable | string>;
};
```

## SortStageOptions

Options defining how a SortStage is evaluated. See [Pipeline.sort()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinesort).

**Signature:**

```typescript
export declare type SortStageOptions = StageOptions & {
  orderings: Ordering[];
};
```

## StageOptions

Options defining how a Stage is evaluated.

**Signature:**

```typescript
export declare type StageOptions = {
  rawOptions?: {
    [name: string]: unknown;
  };
};
```

## SubcollectionStageOptions

Options defining how a `SubcollectionStage` is evaluated.

**Signature:**

```typescript
export declare type SubcollectionStageOptions = StageOptions & {
  path: string;
};
```

## TimeGranularity

Specify time granularity for expressions.

**Signature:**

```typescript
export declare type TimeGranularity =
  | TimeUnit
  | 'week'
  | 'week(monday)'
  | 'week(tuesday)'
  | 'week(wednesday)'
  | 'week(thursday)'
  | 'week(friday)'
  | 'week(saturday)'
  | 'week(sunday)'
  | 'isoweek'
  | 'month'
  | 'quarter'
  | 'year'
  | 'isoyear';
```

## TimePart

Specify time parts for `timestampExtract` expressions.

**Signature:**

```typescript
export declare type TimePart = TimeGranularity | 'dayofweek' | 'dayofyear';
```

## TimeUnit

Specify time units for expressions.

**Signature:**

```typescript
export declare type TimeUnit =
  | 'microsecond'
  | 'millisecond'
  | 'second'
  | 'minute'
  | 'hour'
  | 'day';
```

## UnionStageOptions

Options defining how a UnionStage is evaluated. See [Pipeline.union()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelineunion).

**Signature:**

```typescript
export declare type UnionStageOptions = StageOptions & {
  other: Pipeline;
};
```

## UnnestStageOptions

Represents the specific options available for configuring an `UnnestStage` within a pipeline.

**Signature:**

```typescript
export declare type UnnestStageOptions = StageOptions & {
  selectable: Selectable;
  indexField?: string;
};
```

## UpdateStageOptions

Options for defining an `update` stage in a [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipeline_class).

Each input document is updated in place at the path specified by its `__name__` field. If an input document does not have a `__name__` field (for example, when inputs come from [PipelineSource.literals()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourceliterals) without `__name__` or after `.removeFields('__name__')`), the operation fails.

The `update` stage does not create documents. If the document at an input document's `__name__` path does not exist, the input document is skipped and is not counted in `documents_modified`. When the pipeline is executed with `atomic: true`, the pipeline instead fails with a `NOT_FOUND` error and no documents are updated.

**Signature:**

```typescript
export declare type UpdateStageOptions = StageOptions & {
  transformedFields?: AliasedExpression[];
};
```

## UpsertStageOptions

Options for defining an `upsert` stage in a [Pipeline](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipeline_class).

The target document path for each upserted document is determined by the combination of `collection` and `documentIdExpression`: - \*\*Neither set:\*\* Upserts each input document in place at its existing `__name__` path. If an input document does not have a `__name__` field (for example, when inputs come from [PipelineSource.literals()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourceliterals) without `__name__` or after `.removeFields('__name__')`), the operation fails. - \*\*`collection` only:\*\* Upserts into `collection`. If the input document has a `__name__` field, its document ID is reused; otherwise a new document ID is auto-generated (for example, when inputs come from [PipelineSource.literals()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipelinesource.md.txt#pipelinesourceliterals) or after `.removeFields('__name__')`). - \*\*Both `collection` and `documentIdExpression` set:\*\* Upserts into `collection` using the evaluated document ID.

If no document exists at the target path, it is created. If one exists, it is replaced entirely by the written document; existing fields are not merged.

**Signature:**

```typescript
export declare type UpsertStageOptions = StageOptions & {
  collection?: string | CollectionReference;
  documentIdExpression?: string | Expression;
  additionalFields?: AliasedExpression[];
};
```

## WhereStageOptions

Options defining how a WhereStage is evaluated. See [Pipeline.where()](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.pipeline.md.txt#pipelinewhere).

**Signature:**

```typescript
export declare type WhereStageOptions = StageOptions & {
  condition: BooleanExpression;
};
```

## WindowSpec

> This API is 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 type that specifies a window frame, over which a window function will be evaluated.

Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes

Default frame behavior: - If `sort` is not specified, the default frame is `documents` from `'unbounded'` preceding to `'unbounded'` following (the entire partition/group). - If `sort` is specified, the default frame is `range` from `'unbounded'` preceding to `'current'` following (which includes all documents tied with the current document's sort value(s)).

**Signature:**

```typescript
export declare type WindowSpec = {
  partition?: Array<string | Expression>;
  sort?: Ordering | Ordering[];
} & OneOf<{
  documents?: DocumentWindowFrame;
  range?: RangeWindowFrame;
}>;
```