PipelineResult class

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

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

Signature:

export declare class PipelineResult<AppModelType = DocumentData> 

Properties

Property Modifiers Type Description
createTime Timestamp | undefined The time the document was created. Undefined if this result is not a document.
id string | undefined The ID of the document for which this PipelineResult contains data, if it is a document; otherwise undefined.
ref DocumentReference | undefined The reference of the document, if it is a document; otherwise undefined.
updateTime Timestamp | undefined The time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document.

Methods

Method Modifiers Description
data() Retrieves all fields in the result as an object.
get(fieldPath) Retrieves the field specified by field.

PipelineResult.createTime

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

Signature:

get createTime(): Timestamp | undefined;

PipelineResult.id

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

Signature:

get id(): string | undefined;

PipelineResult.ref

The reference of the document, if it is a document; otherwise undefined.

Signature:

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.

Signature:

get updateTime(): Timestamp | undefined;

PipelineResult.data()

Retrieves all fields in the result as an object.

Signature:

data(): AppModelType;

Returns:

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.

Signature:

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

Parameters

Parameter Type Description
fieldPath string | FieldPath | Field

Returns:

any

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

Example

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

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