CollectionGroup

CollectionGroup

new CollectionGroup()

A CollectionGroup refers to all documents that are contained in a collection or subcollection with a specific collection ID.

Methods

(async, generator) getPartitions(desiredPartitionCount) → {AsyncIterable.<QueryPartition>}

Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned cursors are split points that can be used as starting and end points for individual query invocations.

Parameters:
Name Type Description
desiredPartitionCount number

The desired maximum number of partition points. The number must be strictly positive. The actual number of partitions returned may be fewer.

Returns:
Type Description
AsyncIterable.<QueryPartition>

An AsyncIterable of QueryPartitions.

Example
```
const query = firestore.collectionGroup('collectionId');
for await (const partition of query.getPartitions(42)) {
  const partitionedQuery = partition.toQuery();
  const querySnapshot = await partitionedQuery.get();
  console.log(`Partition contained ${querySnapshot.length} documents`);
}

```