Spaces:
Sleeping
Sleeping
File size: 4,011 Bytes
de5ba48 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | import * as firestore from '@google-cloud/firestore';
import * as protos from '../protos/firestore_v1_proto_api';
import { Query } from './reference';
import { Firestore } from './index';
import api = protos.google.firestore.v1;
/**
* 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 {@link #startAt} and {@link
* #endBefore} can only be used in a query that matches the constraint of query
* that produced this partition.
*
* @class QueryPartition
*/
export declare class QueryPartition<T = firestore.DocumentData> implements firestore.QueryPartition<T> {
private readonly _firestore;
private readonly _collectionId;
private readonly _converter;
private readonly _startAt;
private readonly _endBefore;
private readonly _serializer;
private _memoizedStartAt;
private _memoizedEndBefore;
/** @private */
constructor(_firestore: Firestore, _collectionId: string, _converter: firestore.FirestoreDataConverter<T>, _startAt: api.IValue[] | undefined, _endBefore: api.IValue[] | 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)`).
*
* @example
* ```
* 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`);
* }
*
* ```
* @type {Array<*>}
* @return {Array<*>} A cursor value that can be used with {@link
* Query#startAt} or `undefined` if this is the first partition.
*/
get startAt(): 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)`).
*
* @example
* ```
* 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`);
* }
*
* ```
* @type {Array<*>}
* @return {Array<*>} A cursor value that can be used with {@link
* Query#endBefore} or `undefined` if this is the last partition.
*/
get endBefore(): unknown[] | undefined;
/**
* Returns a query that only encapsulates the documents for this partition.
*
* @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`);
* }
*
* ```
* @return {Query<T>} A query partitioned by a {@link Query#startAt} and
* {@link Query#endBefore} cursor.
*/
toQuery(): Query<T>;
}
|