Readonly
traversableThe underlying traversable.
Readonly
traversalExisting traversal config.
Traverses the entire collection in batches of the size specified in traversal config. Invokes the specified async callback for each batch of document snapshots and immediately moves to the next batch. Does not wait for the callback Promise to resolve before moving to the next batch so there is no guarantee that any given batch will finish processing before a later batch.
An asynchronous callback function to invoke for each batch of document snapshots.
A Promise resolving to an object representing the details of the traversal.
This method throws only when the batch callback throws and the number of retries equals maxBatchRetryCount
.
The last error thrown by the batch callback propagates up to this method.
Complexity:
batchSize
) * (Q(batchSize
) + C(batchSize
) / maxConcurrentBatchCount
))maxConcurrentBatchCount
* (batchSize
* D + S))where:
batchSize
): average batch query timebatchSize
): average callback processing timeTraverses the entire collection in batches of the size specified in traversal config. Invokes the specified callback sequentially for each document snapshot in each batch.
An asynchronous callback function to invoke for each document snapshot in each batch.
Optional
config: Partial<TraverseEachConfig>The sequential traversal configuration.
A Promise resolving to an object representing the details of the traversal. The Promise resolves when the entire traversal ends.
Applies the specified config values to the traverser.
Partial traversal configuration.
A new Traverser object.
Applies the specified exit-early predicate to the traverser. After retrieving each batch, the traverser will evaluate the predicate with the current batch doc snapshots and batch index and decide whether to continue the traversal or exit early.
A synchronous function that takes batch doc snapshots and the 0-based batch index and returns a boolean indicating whether to exit traversal early.
A new Traverser object.
If you have already applied other exit-early predicates to this traverser, this and all the other predicates will be evaluated and the resulting booleans will be OR'd to get the boolean that indicates whether to exit early or not. This is consistent with the intuitive default behavior that the traverser doesn't exit early.
const newTraverser = traverser
.withExitEarlyPredicate((batchDocs) => batchDocs.some((d) => d.get('name') === undefined))
.withExitEarlyPredicate((_, batchIndex) => batchIndex === 99);
In the above case newTraverser
will exit early if the name
field of one of the docs in the batch is
missing OR if the batch index is 99. That is, it will never reach batch 100 and depending on the documents
in the database it may exit earlier than 99.
Generated using TypeDoc
A traverser object that facilitates Firestore collection traversals.