UNPKG

3.15 kBTypeScriptView Raw
1/// <reference lib="esnext.asynciterable" />
2import { ClientContext } from "./ClientContext";
3import { ResourceType } from "./common";
4import { FetchFunctionCallback, SqlQuerySpec } from "./queryExecutionContext";
5import { FeedOptions } from "./request/FeedOptions";
6import { FeedResponse } from "./request/FeedResponse";
7/**
8 * Represents a QueryIterator Object, an implementation of feed or query response that enables
9 * traversal and iterating over the response
10 * in the Azure Cosmos DB database service.
11 */
12export declare class QueryIterator<T> {
13 private clientContext;
14 private query;
15 private options;
16 private fetchFunctions;
17 private resourceLink?;
18 private resourceType?;
19 private fetchAllTempResources;
20 private fetchAllLastResHeaders;
21 private queryExecutionContext;
22 private queryPlanPromise;
23 private isInitialized;
24 /**
25 * @hidden
26 */
27 constructor(clientContext: ClientContext, query: SqlQuerySpec | string, options: FeedOptions, fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[], resourceLink?: string, resourceType?: ResourceType);
28 /**
29 * Gets an async iterator that will yield results until completion.
30 *
31 * NOTE: AsyncIterators are a very new feature and you might need to
32 * use polyfils/etc. in order to use them in your code.
33 *
34 * If you're using TypeScript, you can use the following polyfill as long
35 * as you target ES6 or higher and are running on Node 6 or higher.
36 *
37 * ```typescript
38 * if (!Symbol || !Symbol.asyncIterator) {
39 * (Symbol as any).asyncIterator = Symbol.for("Symbol.asyncIterator");
40 * }
41 * ```
42 *
43 * @example Iterate over all databases
44 * ```typescript
45 * for await(const { resources: db } of client.databases.readAll().getAsyncIterator()) {
46 * console.log(`Got ${db} from AsyncIterator`);
47 * }
48 * ```
49 */
50 getAsyncIterator(): AsyncIterable<FeedResponse<T>>;
51 /**
52 * Determine if there are still remaining resources to processs based on the value of the continuation token or the
53 * elements remaining on the current batch in the QueryIterator.
54 * @returns true if there is other elements to process in the QueryIterator.
55 */
56 hasMoreResults(): boolean;
57 /**
58 * Fetch all pages for the query and return a single FeedResponse.
59 */
60 fetchAll(): Promise<FeedResponse<T>>;
61 /**
62 * Retrieve the next batch from the feed.
63 *
64 * This may or may not fetch more pages from the backend depending on your settings
65 * and the type of query. Aggregate queries will generally fetch all backend pages
66 * before returning the first batch of responses.
67 */
68 fetchNext(): Promise<FeedResponse<T>>;
69 /**
70 * Reset the QueryIterator to the beginning and clear all the resources inside it
71 */
72 reset(): void;
73 private toArrayImplementation;
74 private createPipelinedExecutionContext;
75 private fetchQueryPlan;
76 private needsQueryPlan;
77 private initPromise;
78 private init;
79 private _init;
80 private handleSplitError;
81}
82//# sourceMappingURL=queryIterator.d.ts.map
\No newline at end of file