Back to Firebase Js Sdk

PipelineResult class

docs-devsite/firestore_pipelines.pipelineresult.md

12.12.14.1 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 %}

PipelineResult class

A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the PipelineResult.data() or PipelineResult.get() methods.

<p>If the PipelineResult represents a non-document result, `ref` will return a undefined value.

<b>Signature:</b>

typescript
export declare class PipelineResult<AppModelType = DocumentData> 

Properties

PropertyModifiersTypeDescription
createTimeTimestamp | undefinedThe time the document was created. Undefined if this result is not a document.
idstring | undefinedThe ID of the document for which this PipelineResult contains data, if it is a document; otherwise <code>undefined</code>.
refDocumentReference | undefinedThe reference of the document, if it is a document; otherwise <code>undefined</code>.
updateTimeTimestamp | undefinedThe time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document.

Methods

MethodModifiersDescription
data()Retrieves all fields in the result as an object.
get(fieldPath)Retrieves the field specified by <code>field</code>.

PipelineResult.createTime

The time the document was created. Undefined if this result is not a document.

<b>Signature:</b>

typescript
get createTime(): Timestamp | undefined;

PipelineResult.id

The ID of the document for which this PipelineResult contains data, if it is a document; otherwise undefined<!-- -->.

<b>Signature:</b>

typescript
get id(): string | undefined;

PipelineResult.ref

The reference of the document, if it is a document; otherwise undefined<!-- -->.

<b>Signature:</b>

typescript
get ref(): DocumentReference | undefined;

PipelineResult.updateTime

The time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document.

<b>Signature:</b>

typescript
get updateTime(): Timestamp | undefined;

PipelineResult.data()

Retrieves all fields in the result as an object.

<b>Signature:</b>

typescript
data(): AppModelType;

<b>Returns:</b>

AppModelType

An object containing all fields in the document or 'undefined' if the document doesn't exist.

Example

let p = firestore.pipeline().collection('col');

p.execute().then(results => {
  let data = results[0].data();
  console.log(`Retrieved data: ${JSON.stringify(data)}`);
});

PipelineResult.get()

Retrieves the field specified by field<!-- -->.

<b>Signature:</b>

typescript
get(fieldPath: string | FieldPath | Field): any;

Parameters

ParameterTypeDescription
fieldPathstring | FieldPath | Field

<b>Returns:</b>

any

The data at the specified field location or undefined if no such field exists.

Example

let p = firestore.pipeline().collection('col');

p.execute().then(results => {
  let field = results[0].get('a.b');
  console.log(`Retrieved field value: ${field}`);
});