Back to Firebase Js Sdk

Field class

docs-devsite/firestore_pipelines.field.md

12.12.13.2 KB
Original Source

Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference

{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}

Field class

Represents a reference to a field in a Firestore document, or outputs of a Pipeline stage.

<p>Field references are used to access document field values in expressions and to specify fields for sorting, filtering, and projecting data in Firestore pipelines. <p>You can create a `Field` instance using the static method:

<b>Signature:</b>

typescript
export declare class Field extends Expression implements Selectable 

<b>Extends:</b> Expression

<b>Implements:</b> Selectable

Properties

PropertyModifiersTypeDescription
aliasstring
exprExpression
expressionTypeExpressionType
fieldNamestring
selectabletrue

Methods

MethodModifiersDescription
geoDistance(location)<b><i>(Public Preview)</i></b> Evaluates to the distance in meters between the location specified by this field and the query location.

Field.alias

<b>Signature:</b>

typescript
get alias(): string;

Field.expr

<b>Signature:</b>

typescript
get expr(): Expression;

Field.expressionType

<b>Signature:</b>

typescript
readonly expressionType: ExpressionType;

Field.fieldName

<b>Signature:</b>

typescript
get fieldName(): string;

Field.selectable

<b>Signature:</b>

typescript
selectable: true;

Field.geoDistance()

This API is 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 to the distance in meters between the location specified by this field and the query location.

This Expression can only be used within a Search stage.

<b>Signature:</b>

typescript
geoDistance(location: GeoPoint | Expression): Expression;

Parameters

ParameterTypeDescription
locationGeoPoint | ExpressionCompute distance to this GeoPoint.

<b>Returns:</b>

Expression

Example

typescript
// Create a Field instance for the 'name' field
const nameField = field("name");

// Create a Field instance for a nested field 'address.city'
const cityField = field("address.city");