UNPKG

12.8 kBTypeScriptView Raw
1import { Cluster } from './cluster';
2import { Collection } from './collection';
3import { NodeCallback } from './utilities';
4/**
5 * Contains a specific index configuration for the query service.
6 *
7 * @category Management
8 */
9export declare class QueryIndex {
10 /**
11 * The name of the index.
12 */
13 name: string;
14 /**
15 * Whether this is a primary or secondary index.
16 */
17 isPrimary: boolean;
18 /**
19 * The type of index.
20 */
21 type: string;
22 /**
23 * The current state of the index.
24 */
25 state: string;
26 /**
27 * The keys for this index.
28 */
29 indexKey: string[];
30 /**
31 * The conditional expression to limit the indexes scope.
32 */
33 condition?: string;
34 /**
35 * Information about the partitioning of this index.
36 */
37 partition?: string;
38 /**
39 * The collection that this index is for.
40 */
41 collectionName?: string;
42 /**
43 * The scope that this index is for.
44 */
45 scopeName?: string;
46 /**
47 * The bucket that this index is for.
48 */
49 bucketName?: string;
50 /**
51 * @internal
52 */
53 constructor(data: QueryIndex);
54}
55/**
56 * @category Management
57 */
58export interface CreateQueryIndexOptions {
59 /**
60 * Specifies the collection of this index.
61 *
62 * @deprecated Use {@link CollectionQueryIndexManager} instead.
63 */
64 collectionName?: string;
65 /**
66 * Specifies the collection scope of this index.
67 *
68 * @deprecated Use {@link CollectionQueryIndexManager} instead.
69 */
70 scopeName?: string;
71 /**
72 * Whether or not the call should ignore the index already existing when
73 * determining whether the call was successful.
74 */
75 ignoreIfExists?: boolean;
76 /**
77 * The number of replicas of this index that should be created.
78 */
79 numReplicas?: number;
80 /**
81 * Specifies whether this index creation should be deferred until a later
82 * point in time when they can be explicitly built together.
83 */
84 deferred?: boolean;
85 /**
86 * The timeout for this operation, represented in milliseconds.
87 */
88 timeout?: number;
89}
90/**
91 * @category Management
92 */
93export interface CreatePrimaryQueryIndexOptions {
94 /**
95 * Specifies the collection of this index.
96 *
97 * @deprecated Use {@link CollectionQueryIndexManager} instead.
98 */
99 collectionName?: string;
100 /**
101 * Specifies the collection scope of this index.
102 *
103 * @deprecated Use {@link CollectionQueryIndexManager} instead.
104 */
105 scopeName?: string;
106 /**
107 * The name of this primary index.
108 */
109 name?: string;
110 /**
111 * Whether or not the call should ignore the index already existing when
112 * determining whether the call was successful.
113 */
114 ignoreIfExists?: boolean;
115 /**
116 * The number of replicas of this index that should be created.
117 */
118 numReplicas?: number;
119 /**
120 * Specifies whether this index creation should be deferred until a later
121 * point in time when they can be explicitly built together.
122 */
123 deferred?: boolean;
124 /**
125 * The timeout for this operation, represented in milliseconds.
126 */
127 timeout?: number;
128}
129/**
130 * @category Management
131 */
132export interface DropQueryIndexOptions {
133 /**
134 * Specifies the collection of this index.
135 *
136 * @deprecated Use {@link CollectionQueryIndexManager} instead.
137 */
138 collectionName?: string;
139 /**
140 * Specifies the collection scope of this index.
141 *
142 * @deprecated Use {@link CollectionQueryIndexManager} instead.
143 */
144 scopeName?: string;
145 /**
146 * Whether or not the call should ignore the index already existing when
147 * determining whether the call was successful.
148 */
149 ignoreIfNotExists?: boolean;
150 /**
151 * The timeout for this operation, represented in milliseconds.
152 */
153 timeout?: number;
154}
155/**
156 * @category Management
157 */
158export interface DropPrimaryQueryIndexOptions {
159 /**
160 * Specifies the collection of this index.
161 *
162 * @deprecated Use {@link CollectionQueryIndexManager} instead.
163 */
164 collectionName?: string;
165 /**
166 * Specifies the collection scope of this index.
167 *
168 * @deprecated Use {@link CollectionQueryIndexManager} instead.
169 */
170 scopeName?: string;
171 /**
172 * The name of the primary index to drop.
173 */
174 name?: string;
175 /**
176 * Whether or not the call should ignore the index already existing when
177 * determining whether the call was successful.
178 */
179 ignoreIfNotExists?: boolean;
180 /**
181 * The timeout for this operation, represented in milliseconds.
182 */
183 timeout?: number;
184}
185/**
186 * @category Management
187 */
188export interface GetAllQueryIndexesOptions {
189 /**
190 * Specifies the collection of this index.
191 *
192 * @deprecated Use {@link CollectionQueryIndexManager} instead.
193 */
194 collectionName?: string;
195 /**
196 * Specifies the collection scope of this index.
197 *
198 * @deprecated Use {@link CollectionQueryIndexManager} instead.
199 */
200 scopeName?: string;
201 /**
202 * The timeout for this operation, represented in milliseconds.
203 */
204 timeout?: number;
205}
206/**
207 * @category Management
208 */
209export interface BuildQueryIndexOptions {
210 /**
211 * Specifies the collection of this index.
212 *
213 * @deprecated Use {@link CollectionQueryIndexManager} instead.
214 */
215 collectionName?: string;
216 /**
217 * Specifies the collection scope of this index.
218 *
219 * @deprecated Use {@link CollectionQueryIndexManager} instead.
220 */
221 scopeName?: string;
222 /**
223 * The timeout for this operation, represented in milliseconds.
224 */
225 timeout?: number;
226}
227/**
228 * @category Management
229 */
230export interface WatchQueryIndexOptions {
231 /**
232 * Specifies the collection of this index.
233 *
234 * @deprecated Use {@link CollectionQueryIndexManager} instead.
235 */
236 collectionName?: string;
237 /**
238 * Specifies the collection scope of this index.
239 *
240 * @deprecated Use {@link CollectionQueryIndexManager} instead.
241 */
242 scopeName?: string;
243 /**
244 * Specifies whether the primary indexes should be watched as well.
245 */
246 watchPrimary?: boolean;
247}
248/**
249 * CollectionQueryIndexManager provides an interface for managing the
250 * query indexes on the collection.
251 *
252 * @category Management
253 */
254export declare class CollectionQueryIndexManager {
255 private _bucketName;
256 private _collectionName;
257 private _manager;
258 private _scopeName;
259 /**
260 * @internal
261 */
262 constructor(collection: Collection);
263 /**
264 * Creates a new query index.
265 *
266 * @param indexName The name of the new index.
267 * @param keys The keys which this index should cover.
268 * @param options Optional parameters for this operation.
269 * @param callback A node-style callback to be invoked after execution.
270 */
271 createIndex(indexName: string, keys: string[], options?: CreateQueryIndexOptions, callback?: NodeCallback<void>): Promise<void>;
272 /**
273 * Creates a new primary query index.
274 *
275 * @param options Optional parameters for this operation.
276 * @param callback A node-style callback to be invoked after execution.
277 */
278 createPrimaryIndex(options?: CreatePrimaryQueryIndexOptions, callback?: NodeCallback<void>): Promise<void>;
279 /**
280 * Drops an existing query index.
281 *
282 * @param indexName The name of the index to drop.
283 * @param options Optional parameters for this operation.
284 * @param callback A node-style callback to be invoked after execution.
285 */
286 dropIndex(indexName: string, options?: DropQueryIndexOptions, callback?: NodeCallback<void>): Promise<void>;
287 /**
288 * Drops an existing primary index.
289 *
290 * @param options Optional parameters for this operation.
291 * @param callback A node-style callback to be invoked after execution.
292 */
293 dropPrimaryIndex(options?: DropPrimaryQueryIndexOptions, callback?: NodeCallback<void>): Promise<void>;
294 /**
295 * Returns a list of indexes for a specific bucket.
296 *
297 * @param options Optional parameters for this operation.
298 * @param callback A node-style callback to be invoked after execution.
299 */
300 getAllIndexes(options?: GetAllQueryIndexesOptions, callback?: NodeCallback<QueryIndex[]>): Promise<QueryIndex[]>;
301 /**
302 * Starts building any indexes which were previously created with deferred=true.
303 *
304 * @param options Optional parameters for this operation.
305 * @param callback A node-style callback to be invoked after execution.
306 */
307 buildDeferredIndexes(options?: BuildQueryIndexOptions, callback?: NodeCallback<string[]>): Promise<string[]>;
308 /**
309 * Waits for a number of indexes to finish creation and be ready to use.
310 *
311 * @param indexNames The names of the indexes to watch.
312 * @param timeout The maximum time to wait for the index, expressed in milliseconds.
313 * @param options Optional parameters for this operation.
314 * @param callback A node-style callback to be invoked after execution.
315 */
316 watchIndexes(indexNames: string[], timeout: number, options?: WatchQueryIndexOptions, callback?: NodeCallback<void>): Promise<void>;
317}
318/**
319 * QueryIndexManager provides an interface for managing the
320 * query indexes on the cluster.
321 *
322 * @category Management
323 */
324export declare class QueryIndexManager {
325 private _manager;
326 /**
327 * @internal
328 */
329 constructor(cluster: Cluster);
330 /**
331 * Creates a new query index.
332 *
333 * @param bucketName The name of the bucket this index is for.
334 * @param indexName The name of the new index.
335 * @param keys The keys which this index should cover.
336 * @param options Optional parameters for this operation.
337 * @param callback A node-style callback to be invoked after execution.
338 */
339 createIndex(bucketName: string, indexName: string, keys: string[], options?: CreateQueryIndexOptions, callback?: NodeCallback<void>): Promise<void>;
340 /**
341 * Creates a new primary query index.
342 *
343 * @param bucketName The name of the bucket this index is for.
344 * @param options Optional parameters for this operation.
345 * @param callback A node-style callback to be invoked after execution.
346 */
347 createPrimaryIndex(bucketName: string, options?: CreatePrimaryQueryIndexOptions, callback?: NodeCallback<void>): Promise<void>;
348 /**
349 * Drops an existing query index.
350 *
351 * @param bucketName The name of the bucket containing the index to drop.
352 * @param indexName The name of the index to drop.
353 * @param options Optional parameters for this operation.
354 * @param callback A node-style callback to be invoked after execution.
355 */
356 dropIndex(bucketName: string, indexName: string, options?: DropQueryIndexOptions, callback?: NodeCallback<void>): Promise<void>;
357 /**
358 * Drops an existing primary index.
359 *
360 * @param bucketName The name of the bucket containing the primary index to drop.
361 * @param options Optional parameters for this operation.
362 * @param callback A node-style callback to be invoked after execution.
363 */
364 dropPrimaryIndex(bucketName: string, options?: DropPrimaryQueryIndexOptions, callback?: NodeCallback<void>): Promise<void>;
365 /**
366 * Returns a list of indexes for a specific bucket.
367 *
368 * @param bucketName The name of the bucket to fetch indexes for.
369 * @param options Optional parameters for this operation.
370 * @param callback A node-style callback to be invoked after execution.
371 */
372 getAllIndexes(bucketName: string, options?: GetAllQueryIndexesOptions, callback?: NodeCallback<QueryIndex[]>): Promise<QueryIndex[]>;
373 /**
374 * Starts building any indexes which were previously created with deferred=true.
375 *
376 * @param bucketName The name of the bucket to perform the build on.
377 * @param options Optional parameters for this operation.
378 * @param callback A node-style callback to be invoked after execution.
379 */
380 buildDeferredIndexes(bucketName: string, options?: BuildQueryIndexOptions, callback?: NodeCallback<string[]>): Promise<string[]>;
381 /**
382 * Waits for a number of indexes to finish creation and be ready to use.
383 *
384 * @param bucketName The name of the bucket to watch for indexes on.
385 * @param indexNames The names of the indexes to watch.
386 * @param timeout The maximum time to wait for the index, expressed in milliseconds.
387 * @param options Optional parameters for this operation.
388 * @param callback A node-style callback to be invoked after execution.
389 */
390 watchIndexes(bucketName: string, indexNames: string[], timeout: number, options?: WatchQueryIndexOptions, callback?: NodeCallback<void>): Promise<void>;
391}