UNPKG

8.43 kBTypeScriptView Raw
1import { MutationState } from './mutationstate';
2/**
3 * Represents the status of a query.
4 *
5 * @category Query
6 */
7export declare enum QueryStatus {
8 /**
9 * Indicates the query is still running.
10 */
11 Running = "running",
12 /**
13 * Indicates that the query completed successfully.
14 */
15 Success = "success",
16 /**
17 * Indicates that the query completed with errors.
18 */
19 Errors = "errors",
20 /**
21 * Indicates that the query completed but the outcome was unknown.
22 */
23 Completed = "completed",
24 /**
25 * Indicates that the query was stopped.
26 */
27 Stopped = "stopped",
28 /**
29 * Indicates that the query timed out during execution.
30 */
31 Timeout = "timeout",
32 /**
33 * Indicates that a connection was closed during execution of the query.
34 */
35 Closed = "closed",
36 /**
37 * Indicates that the query stopped with fatal errors.
38 */
39 Fatal = "fatal",
40 /**
41 * Indicates that the query was aborted while executing.
42 */
43 Aborted = "aborted",
44 /**
45 * Indicates that the status of the query is unknown.
46 */
47 Unknown = "unknown"
48}
49/**
50 * Contains the results of a query.
51 *
52 * @category Query
53 */
54export declare class QueryResult<TRow = any> {
55 /**
56 * The rows which have been returned by the query.
57 */
58 rows: TRow[];
59 /**
60 * The meta-data which has been returned by the query.
61 */
62 meta: QueryMetaData;
63 /**
64 * @internal
65 */
66 constructor(data: QueryResult);
67}
68/**
69 * Contains the meta-data that is returend from a query.
70 *
71 * @category Query
72 */
73export declare class QueryMetaData {
74 /**
75 * The request ID which is associated with the executed query.
76 */
77 requestId: string;
78 /**
79 * The client context id which is assoicated with the executed query.
80 */
81 clientContextId: string;
82 /**
83 * The status of the query at the time the query meta-data was generated.
84 */
85 status: QueryStatus;
86 /**
87 * Provides the signature of the query.
88 */
89 signature?: any;
90 /**
91 * Any warnings that occurred during the execution of the query.
92 */
93 warnings: QueryWarning[];
94 /**
95 * Various metrics which are made available by the query engine.
96 */
97 metrics?: QueryMetrics;
98 /**
99 * Various profiling details that were generated during execution of the query.
100 */
101 profile?: any;
102 /**
103 * @internal
104 */
105 constructor(data: QueryMetaData);
106}
107/**
108 * Contains information about a warning which occurred during the
109 * execution of a query.
110 *
111 * @category Query
112 */
113export declare class QueryWarning {
114 /**
115 * The numeric code associated with the warning which occurred.
116 */
117 code: number;
118 /**
119 * A human readable representation of the warning which occurred.
120 */
121 message: string;
122 /**
123 * @internal
124 */
125 constructor(data: QueryWarning);
126}
127/**
128 * Contains various metrics that are returned by the server following
129 * the execution of a query.
130 *
131 * @category Query
132 */
133export declare class QueryMetrics {
134 /**
135 * The total amount of time spent running the query, in milliseconds.
136 */
137 elapsedTime: number;
138 /**
139 * The total amount of time spent executing the query, in milliseconds.
140 */
141 executionTime: number;
142 /**
143 * The total number of rows which were part of the sorting for the query.
144 */
145 sortCount: number;
146 /**
147 * The total number of rows which were part of the result set.
148 */
149 resultCount: number;
150 /**
151 * The total number of bytes which were generated as part of the result set.
152 */
153 resultSize: number;
154 /**
155 * The total number of rows which were altered by the query.
156 */
157 mutationCount: number;
158 /**
159 * The total number of errors which were encountered during the execution of the query.
160 */
161 errorCount: number;
162 /**
163 * The total number of warnings which were encountered during the execution of the query.
164 */
165 warningCount: number;
166 /**
167 * @internal
168 */
169 constructor(data: QueryMetrics);
170}
171/**
172 * Specifies the profiling mode for a query.
173 *
174 * @category Query
175 */
176export declare enum QueryProfileMode {
177 /**
178 * Disables the generation of profiling data.
179 */
180 Off = "off",
181 /**
182 * Enables profiling of the phases of a query.
183 */
184 Phases = "phases",
185 /**
186 * Enables profiling of the timings of a query.
187 */
188 Timings = "timings"
189}
190/**
191 * Represents the various scan consistency options that are available when
192 * querying against the query service.
193 *
194 * @category Query
195 */
196export declare enum QueryScanConsistency {
197 /**
198 * Indicates that no specific consistency is required, this is the fastest
199 * options, but results may not include the most recent operations which have
200 * been performed.
201 */
202 NotBounded = "not_bounded",
203 /**
204 * Indicates that the results to the query should include all operations that
205 * have occurred up until the query was started. This incurs a performance
206 * penalty of waiting for the index to catch up to the most recent operations,
207 * but provides the highest level of consistency.
208 */
209 RequestPlus = "request_plus"
210}
211/**
212 * @category Query
213 */
214export interface QueryOptions {
215 /**
216 * Values to be used for the placeholders within the query.
217 */
218 parameters?: {
219 [key: string]: any;
220 } | any[];
221 /**
222 * Specifies the consistency requirements when executing the query.
223 *
224 * @see QueryScanConsistency
225 */
226 scanConsistency?: QueryScanConsistency;
227 /**
228 * Specifies a MutationState which the query should be consistent with.
229 *
230 * @see {@link MutationState}
231 */
232 consistentWith?: MutationState;
233 /**
234 * Specifies whether this is an ad-hoc query, or if it should be prepared
235 * for faster execution in the future.
236 */
237 adhoc?: boolean;
238 /**
239 * Specifies whether flex-indexes should be enabled. Allowing the use of
240 * full-text search from the query service.
241 */
242 flexIndex?: boolean;
243 /**
244 * Specifies that the query should preserve the existing document expiry times
245 * when mutating documents.
246 */
247 preserveExpiry?: boolean;
248 /**
249 * The returned client context id for this query.
250 */
251 clientContextId?: string;
252 /**
253 * This is an advanced option, see the query service reference for more
254 * information on the proper use and tuning of this option.
255 */
256 maxParallelism?: number;
257 /**
258 * This is an advanced option, see the query service reference for more
259 * information on the proper use and tuning of this option.
260 */
261 pipelineBatch?: number;
262 /**
263 * This is an advanced option, see the query service reference for more
264 * information on the proper use and tuning of this option.
265 */
266 pipelineCap?: number;
267 /**
268 * This is an advanced option, see the query service reference for more
269 * information on the proper use and tuning of this option. Specified
270 * in milliseconds.
271 */
272 scanWait?: number;
273 /**
274 * This is an advanced option, see the query service reference for more
275 * information on the proper use and tuning of this option.
276 */
277 scanCap?: number;
278 /**
279 * Specifies that this query should be executed in read-only mode, disabling
280 * the ability for the query to make any changes to the data.
281 */
282 readOnly?: boolean;
283 /**
284 * Specifies whether the query engine should use replica nodes for kv fetches,
285 * if the active node is down.
286 */
287 useReplica?: boolean;
288 /**
289 * Specifies the level of profiling that should be used for the query.
290 */
291 profile?: QueryProfileMode;
292 /**
293 * Specifies whether metrics should be captured as part of the execution of
294 * the query.
295 */
296 metrics?: boolean;
297 /**
298 * Specifies the context within which this query should be executed. This can be
299 * scoped to a scope or a collection within the dataset.
300 */
301 queryContext?: string;
302 /**
303 * Specifies any additional parameters which should be passed to the query engine
304 * when executing the query.
305 */
306 raw?: {
307 [key: string]: any;
308 };
309 /**
310 * The timeout for this operation, represented in milliseconds.
311 */
312 timeout?: number;
313}