Stay organized with collections Save and categorize content based on your preferences.
A split point that can be used in a query as a starting and/or end point for the query results. The cursors returned by and can only be used in a query that matches the constraint of query that produced this partition.
QueryPartition
Package@google-cloud/firestore Constructors (constructor)(_firestore, _collectionId, _converter, _startAt, _endBefore)constructor(_firestore: Firestore, _collectionId: string, _converter: firestore.FirestoreDataConverter<AppModelType, DbModelType>, _startAt: api.IValue[] | undefined, _endBefore: api.IValue[] | undefined);
Constructs a new instance of the QueryPartition
class
_firestore
Firestore
_collectionId
string
_converter
FirebaseFirestore.FirestoreDataConverter<AppModelType, DbModelType>
_startAt
google.firestore.v1.IValue[] | undefined
_endBefore
google.firestore.v1.IValue[] | undefined
get endBefore(): unknown[] | undefined;
The cursor that defines the first result after this partition or undefined
if this is the last partition. The cursor value must be destructured when passed to endBefore()
(for example with query.endBefore(...queryPartition.endBefore)
).
const query = firestore.collectionGroup('collectionId');
for await (const partition of query.getPartitions(42)) {
let partitionedQuery = query.orderBy(FieldPath.documentId());
if (partition.startAt) {
partitionedQuery = partitionedQuery.startAt(...partition.startAt);
}
if (partition.endBefore) {
partitionedQuery = partitionedQuery.endBefore(...partition.endBefore);
}
const querySnapshot = await partitionedQuery.get();
console.log(`Partition contained ${querySnapshot.length} documents`);
}
{Array<*>} {Array<*>} A cursor value that can be used with or undefined
if this is the last partition.
get startAt(): unknown[] | undefined;
The cursor that defines the first result for this partition or undefined
if this is the first partition. The cursor value must be destructured when passed to startAt()
(for example with query.startAt(...queryPartition.startAt)
).
const query = firestore.collectionGroup('collectionId');
for await (const partition of query.getPartitions(42)) {
let partitionedQuery = query.orderBy(FieldPath.documentId());
if (partition.startAt) {
partitionedQuery = partitionedQuery.startAt(...partition.startAt);
}
if (partition.endBefore) {
partitionedQuery = partitionedQuery.endBefore(...partition.endBefore);
}
const querySnapshot = await partitionedQuery.get();
console.log(`Partition contained ${querySnapshot.length} documents`);
}
{Array<*>} {Array<*>} A cursor value that can be used with or undefined
if this is the first partition.
toQuery(): Query<AppModelType, DbModelType>;
Returns a query that only encapsulates the documents for this partition.
Returns Type DescriptionQuery<AppModelType, DbModelType>
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`);
}
{Query
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4