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

> This API is 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 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-notes

A `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).

**Signature:**

```typescript
export declare class WindowFunction 
```

## Constructors

| Constructor | Modifiers | Description |
|---|---|---|
| [(constructor)(name, params)](https://firebase.google.com/docs/reference/js/firestore_pipelines.windowfunction.md.txt#windowfunctionconstructor) |   | ***(Public Preview)*** Constructs a new instance of the `WindowFunction` class |

## Properties

| Property | Modifiers | Type | Description |
|---|---|---|---|
| [exprType](https://firebase.google.com/docs/reference/js/firestore_pipelines.windowfunction.md.txt#windowfunctionexprtype) |   | [ExpressionType](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#expressiontype) | ***(Public Preview)*** |

## Methods

| Method | Modifiers | Description |
|---|---|---|
| [as(name)](https://firebase.google.com/docs/reference/js/firestore_pipelines.windowfunction.md.txt#windowfunctionas) |   | ***(Public Preview)*** Assigns an alias to this `WindowFunction`. The alias specifies the name that the computed value will have in the output 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-notes |
| [over(frame)](https://firebase.google.com/docs/reference/js/firestore_pipelines.windowfunction.md.txt#windowfunctionover) |   | ***(Public Preview)*** Evaluates this window function over a specific window frame, rather than over the window frame defined by the enclosing [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-notesThe backend only accepts a frame (`documents` or `range`) here, and rejects `partition` and `sort`, which must be specified on the enclosing `addWindowFields()` stage.- In a `documents` frame, bounds are document offsets relative to the current document's position (`'current'` refers strictly to the current document's position; tied documents are not included). For `preceding`, a positive integer (e.g. `2`) includes up to that many documents before the current document, and a negative integer (e.g. `-1`) indicates a boundary following the current document, enabling frames that start after the current document. For `following`, a positive integer (e.g. `2`) includes up to that many documents after the current document, and a negative integer (e.g. `-1`) indicates a boundary preceding the current document, enabling frames that end before the current document (e.g. excluding the current document). - In a `range` frame, bounds are value or time offsets relative to the current document's sort value(s) (`'current'` is peer-inclusive and includes all documents tied with the current document's sort value(s), equivalent to an offset of `0`). For `preceding`, a positive offset subtracts from the current document's sort value (looking into the past), and a negative offset adds to the current document's sort value (shifting the lower boundary past the current document). For `following`, a positive offset adds to the current document's sort value (looking into the future), and a negative offset subtracts from the current document's sort value (shifting the upper boundary before the current document). Range frames with numeric or time-unit offsets require a single numeric or timestamp `sort` ordering on the enclosing stage, whereas range frames bounded only by `'current'` and `'unbounded'` support multiple `sort` orderings and non-numeric sort values. |

## WindowFunction.(constructor)

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Constructs a new instance of the `WindowFunction` class

**Signature:**

```typescript
constructor(name: string, params?: Expression[]);
```

#### Parameters

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

## WindowFunction.exprType

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

**Signature:**

```typescript
exprType: ExpressionType;
```

## WindowFunction.as()

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Assigns an alias to this `WindowFunction`. The alias specifies the name that the computed value will have in the output 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-notes

**Signature:**

```typescript
as(name: string): AliasedWindowFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| name | string | The alias to assign to this `WindowFunction`. |

**Returns:**

[AliasedWindowFunction](https://firebase.google.com/docs/reference/js/firestore_pipelines.aliasedwindowfunction.md.txt#aliasedwindowfunction_class)

A new [AliasedWindowFunction](https://firebase.google.com/docs/reference/js/firestore_lite_pipelines.aliasedwindowfunction.md.txt#aliasedwindowfunction_class).

## WindowFunction.over()

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Evaluates this window function over a specific window frame, rather than over the window frame defined by the enclosing [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-notes

The backend only accepts a frame (`documents` or `range`) here, and rejects `partition` and `sort`, which must be specified on the enclosing `addWindowFields()` stage.

- In a `documents` frame, bounds are document offsets relative to the current document's position (`'current'` refers strictly to the current document's position; tied documents are not included). For `preceding`, a positive integer (e.g. `2`) includes up to that many documents before the current document, and a negative integer (e.g. `-1`) indicates a boundary following the current document, enabling frames that start after the current document. For `following`, a positive integer (e.g. `2`) includes up to that many documents after the current document, and a negative integer (e.g. `-1`) indicates a boundary preceding the current document, enabling frames that end before the current document (e.g. excluding the current document). - In a `range` frame, bounds are value or time offsets relative to the current document's sort value(s) (`'current'` is peer-inclusive and includes all documents tied with the current document's sort value(s), equivalent to an offset of `0`). For `preceding`, a positive offset subtracts from the current document's sort value (looking into the past), and a negative offset adds to the current document's sort value (shifting the lower boundary past the current document). For `following`, a positive offset adds to the current document's sort value (looking into the future), and a negative offset subtracts from the current document's sort value (shifting the upper boundary before the current document). Range frames with numeric or time-unit offsets require a single numeric or timestamp `sort` ordering on the enclosing stage, whereas range frames bounded only by `'current'` and `'unbounded'` support multiple `sort` orderings and non-numeric sort values.

**Signature:**

```typescript
over(
    frame: OneOf<{
      documents: DocumentWindowFrame;
      range: RangeWindowFrame;
    }>
  ): WindowFunction;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| frame | [OneOf](https://firebase.google.com/docs/reference/js/firestore_pipelines.md.txt#oneof)\<{ documents: [DocumentWindowFrame](https://firebase.google.com/docs/reference/js/firestore_pipelines.documentwindowframe.md.txt#documentwindowframe_interface); range: [RangeWindowFrame](https://firebase.google.com/docs/reference/js/firestore_pipelines.rangewindowframe.md.txt#rangewindowframe_interface); }\> | The `documents` or `range` window frame to evaluate this function over. |

**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).