BundleBuilder

BundleBuilder

Builds a Firestore data bundle with results from the given document and query snapshots.

Constructor

new BundleBuilder()

Methods

add(documentOrName, querySnapshotopt) → {BundleBuilder}

Adds a Firestore document snapshot or query snapshot to the bundle. Both the documents data and the query read time will be included in the bundle.

Parameters:
Name Type Attributes Description
documentOrName DocumentSnapshot | string

A document snapshot to add or a name of a query.

querySnapshot Query <optional>

A query snapshot to add to the bundle, if provided.

Returns:
Type Description
BundleBuilder

This instance.

Example
const bundle = firestore.bundle('data-bundle');
const docSnapshot = await firestore.doc('abc/123').get();
const querySnapshot = await firestore.collection('coll').get();

const bundleBuffer = bundle.add(docSnapshot); // Add a document
                           .add('coll-query', querySnapshot) // Add a named query.
                           .build()
// Save `bundleBuffer` to CDN or stream it to clients.