1 |
|
2 | import { IncrementOptions, DecrementOptions, AppendOptions, PrependOptions, BinaryCollection } from './binarycollection';
|
3 | import { CppDocumentId, CppConnection, CppScanIterator, CppRangeScanOrchestratorOptions } from './binding';
|
4 | import { Cluster } from './cluster';
|
5 | import { CounterResult, ExistsResult, GetReplicaResult, GetResult, LookupInResult, LookupInReplicaResult, MutateInResult, MutationResult, ScanResult } from './crudoptypes';
|
6 | import { CouchbaseList, CouchbaseMap, CouchbaseQueue, CouchbaseSet } from './datastructures';
|
7 | import { DurabilityLevel, StoreSemantics } from './generaltypes';
|
8 | import { MutationState } from './mutationstate';
|
9 | import { CollectionQueryIndexManager } from './queryindexmanager';
|
10 | import { RangeScan, SamplingScan, PrefixScan } from './rangeScan';
|
11 | import { Scope } from './scope';
|
12 | import { LookupInSpec, MutateInSpec } from './sdspecs';
|
13 | import { StreamableReplicasPromise, StreamableScanPromise } from './streamablepromises';
|
14 | import { Transcoder } from './transcoders';
|
15 | import { NodeCallback, CasInput } from './utilities';
|
16 |
|
17 |
|
18 |
|
19 | export interface GetOptions {
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 | project?: string[];
|
26 | |
27 |
|
28 |
|
29 |
|
30 | withExpiry?: boolean;
|
31 | |
32 |
|
33 |
|
34 | transcoder?: Transcoder;
|
35 | |
36 |
|
37 |
|
38 | timeout?: number;
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 | export interface ExistsOptions {
|
44 | |
45 |
|
46 |
|
47 | timeout?: number;
|
48 | }
|
49 |
|
50 |
|
51 |
|
52 | export interface InsertOptions {
|
53 | |
54 |
|
55 |
|
56 | expiry?: number;
|
57 | |
58 |
|
59 |
|
60 | durabilityLevel?: DurabilityLevel;
|
61 | |
62 |
|
63 |
|
64 |
|
65 |
|
66 | durabilityPersistTo?: number;
|
67 | |
68 |
|
69 |
|
70 |
|
71 |
|
72 | durabilityReplicateTo?: number;
|
73 | |
74 |
|
75 |
|
76 | transcoder?: Transcoder;
|
77 | |
78 |
|
79 |
|
80 | timeout?: number;
|
81 | }
|
82 |
|
83 |
|
84 |
|
85 | export interface UpsertOptions {
|
86 | |
87 |
|
88 |
|
89 | expiry?: number;
|
90 | |
91 |
|
92 |
|
93 | preserveExpiry?: boolean;
|
94 | |
95 |
|
96 |
|
97 | durabilityLevel?: DurabilityLevel;
|
98 | |
99 |
|
100 |
|
101 |
|
102 |
|
103 | durabilityPersistTo?: number;
|
104 | |
105 |
|
106 |
|
107 |
|
108 |
|
109 | durabilityReplicateTo?: number;
|
110 | |
111 |
|
112 |
|
113 | transcoder?: Transcoder;
|
114 | |
115 |
|
116 |
|
117 | timeout?: number;
|
118 | }
|
119 |
|
120 |
|
121 |
|
122 | export interface ReplaceOptions {
|
123 | |
124 |
|
125 |
|
126 | expiry?: number;
|
127 | |
128 |
|
129 |
|
130 | preserveExpiry?: boolean;
|
131 | |
132 |
|
133 |
|
134 |
|
135 | cas?: CasInput;
|
136 | |
137 |
|
138 |
|
139 | durabilityLevel?: DurabilityLevel;
|
140 | |
141 |
|
142 |
|
143 |
|
144 |
|
145 | durabilityPersistTo?: number;
|
146 | |
147 |
|
148 |
|
149 |
|
150 |
|
151 | durabilityReplicateTo?: number;
|
152 | |
153 |
|
154 |
|
155 | transcoder?: Transcoder;
|
156 | |
157 |
|
158 |
|
159 | timeout?: number;
|
160 | }
|
161 |
|
162 |
|
163 |
|
164 | export interface RemoveOptions {
|
165 | |
166 |
|
167 |
|
168 |
|
169 | cas?: CasInput;
|
170 | |
171 |
|
172 |
|
173 | durabilityLevel?: DurabilityLevel;
|
174 | |
175 |
|
176 |
|
177 |
|
178 |
|
179 | durabilityPersistTo?: number;
|
180 | |
181 |
|
182 |
|
183 |
|
184 |
|
185 | durabilityReplicateTo?: number;
|
186 | |
187 |
|
188 |
|
189 | timeout?: number;
|
190 | }
|
191 |
|
192 |
|
193 |
|
194 | export interface GetAnyReplicaOptions {
|
195 | |
196 |
|
197 |
|
198 | transcoder?: Transcoder;
|
199 | |
200 |
|
201 |
|
202 | timeout?: number;
|
203 | }
|
204 |
|
205 |
|
206 |
|
207 | export interface GetAllReplicasOptions {
|
208 | |
209 |
|
210 |
|
211 | transcoder?: Transcoder;
|
212 | |
213 |
|
214 |
|
215 | timeout?: number;
|
216 | }
|
217 |
|
218 |
|
219 |
|
220 | export interface TouchOptions {
|
221 | |
222 |
|
223 |
|
224 | durabilityLevel?: DurabilityLevel;
|
225 | |
226 |
|
227 |
|
228 | timeout?: number;
|
229 | }
|
230 |
|
231 |
|
232 |
|
233 | export interface GetAndTouchOptions {
|
234 | |
235 |
|
236 |
|
237 | transcoder?: Transcoder;
|
238 | |
239 |
|
240 |
|
241 | timeout?: number;
|
242 | }
|
243 |
|
244 |
|
245 |
|
246 | export interface GetAndLockOptions {
|
247 | |
248 |
|
249 |
|
250 | transcoder?: Transcoder;
|
251 | |
252 |
|
253 |
|
254 | timeout?: number;
|
255 | }
|
256 |
|
257 |
|
258 |
|
259 | export interface UnlockOptions {
|
260 | |
261 |
|
262 |
|
263 | timeout?: number;
|
264 | }
|
265 |
|
266 |
|
267 |
|
268 | export interface LookupInOptions {
|
269 | |
270 |
|
271 |
|
272 | timeout?: number;
|
273 | |
274 |
|
275 |
|
276 |
|
277 |
|
278 | accessDeleted?: boolean;
|
279 | }
|
280 |
|
281 |
|
282 |
|
283 | export interface LookupInAnyReplicaOptions {
|
284 | |
285 |
|
286 |
|
287 | timeout?: number;
|
288 | }
|
289 |
|
290 |
|
291 |
|
292 | export interface LookupInAllReplicasOptions {
|
293 | |
294 |
|
295 |
|
296 | timeout?: number;
|
297 | }
|
298 |
|
299 |
|
300 |
|
301 | export interface MutateInOptions {
|
302 | |
303 |
|
304 |
|
305 | expiry?: number;
|
306 | |
307 |
|
308 |
|
309 | preserveExpiry?: boolean;
|
310 | |
311 |
|
312 |
|
313 |
|
314 | cas?: CasInput;
|
315 | |
316 |
|
317 |
|
318 | durabilityLevel?: DurabilityLevel;
|
319 | |
320 |
|
321 |
|
322 |
|
323 |
|
324 | durabilityPersistTo?: number;
|
325 | |
326 |
|
327 |
|
328 |
|
329 |
|
330 | durabilityReplicateTo?: number;
|
331 | |
332 |
|
333 |
|
334 | storeSemantics?: StoreSemantics;
|
335 | |
336 |
|
337 |
|
338 | timeout?: number;
|
339 | |
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 | upsertDocument?: boolean;
|
346 | }
|
347 |
|
348 |
|
349 |
|
350 | export interface ScanOptions {
|
351 | |
352 |
|
353 |
|
354 | transcoder?: Transcoder;
|
355 | |
356 |
|
357 |
|
358 | timeout?: number;
|
359 | |
360 |
|
361 |
|
362 | idsOnly?: boolean;
|
363 | |
364 |
|
365 |
|
366 |
|
367 | batchByteLimit?: number;
|
368 | |
369 |
|
370 |
|
371 |
|
372 | batchItemLimit?: number;
|
373 | |
374 |
|
375 |
|
376 |
|
377 |
|
378 | consistentWith?: MutationState;
|
379 | |
380 |
|
381 |
|
382 | concurrency?: number;
|
383 | }
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 | export declare class Collection {
|
391 | |
392 |
|
393 |
|
394 | static get DEFAULT_NAME(): string;
|
395 | private _scope;
|
396 | private _name;
|
397 | private _conn;
|
398 | private _kvScanTimeout;
|
399 | private _scanBatchItemLimit;
|
400 | private _scanBatchByteLimit;
|
401 | |
402 |
|
403 |
|
404 | constructor(scope: Scope, collectionName: string);
|
405 | /**
|
406 | @internal
|
407 | */
|
408 | get conn(): CppConnection;
|
409 | /**
|
410 | @internal
|
411 | */
|
412 | get cluster(): Cluster;
|
413 | /**
|
414 | @internal
|
415 | */
|
416 | get scope(): Scope;
|
417 | /**
|
418 | @internal
|
419 | */
|
420 | get transcoder(): Transcoder;
|
421 | /**
|
422 | @internal
|
423 | */
|
424 | _mutationTimeout(durabilityLevel?: DurabilityLevel): number;
|
425 | /**
|
426 | * @internal
|
427 | */
|
428 | _cppDocId(key: string): CppDocumentId;
|
429 | /**
|
430 | * @internal
|
431 | */
|
432 | _encodeDoc(transcoder: Transcoder, value: any, callback: (err: Error | null, bytes: Buffer, flags: number) => void): void;
|
433 | /**
|
434 | * @internal
|
435 | */
|
436 | _decodeDoc(transcoder: Transcoder, bytes: Buffer, flags: number, callback: (err: Error | null, content: any) => void): void;
|
437 | /**
|
438 | * @internal
|
439 | */
|
440 | _subdocEncode(value: any): any;
|
441 | /**
|
442 | * @internal
|
443 | */
|
444 | _subdocDecode(bytes: Buffer): any;
|
445 | /**
|
446 | * The name of the collection this Collection object references.
|
447 | */
|
448 | get name(): string;
|
449 | /**
|
450 | * Retrieves the value of a document from the collection.
|
451 | *
|
452 | * @param key The document key to retrieve.
|
453 | * @param options Optional parameters for this operation.
|
454 | * @param callback A node-style callback to be invoked after execution.
|
455 | */
|
456 | get(key: string, options?: GetOptions, callback?: NodeCallback<GetResult>): Promise<GetResult>;
|
457 | private _projectedGet;
|
458 | /**
|
459 | * Checks whether a specific document exists or not.
|
460 | *
|
461 | * @param key The document key to check for existence.
|
462 | * @param options Optional parameters for this operation.
|
463 | * @param callback A node-style callback to be invoked after execution.
|
464 | */
|
465 | exists(key: string, options?: ExistsOptions, callback?: NodeCallback<ExistsResult>): Promise<ExistsResult>;
|
466 | /**
|
467 | * @internal
|
468 | */
|
469 | _getReplica(key: string, getAllReplicas: boolean, options?: {
|
470 | transcoder?: Transcoder;
|
471 | timeout?: number;
|
472 | }, callback?: NodeCallback<GetReplicaResult[]>): StreamableReplicasPromise<GetReplicaResult[], GetReplicaResult>;
|
473 | /**
|
474 | * Retrieves the value of the document from any of the available replicas. This
|
475 | * will return as soon as the first response is received from any replica node.
|
476 | *
|
477 | * @param key The document key to retrieve.
|
478 | * @param options Optional parameters for this operation.
|
479 | * @param callback A node-style callback to be invoked after execution.
|
480 | */
|
481 | getAnyReplica(key: string, options?: GetAnyReplicaOptions, callback?: NodeCallback<GetReplicaResult>): Promise<GetReplicaResult>;
|
482 | /**
|
483 | * Retrieves the value of the document from all available replicas. Note that
|
484 | * as replication is asynchronous, each node may return a different value.
|
485 | *
|
486 | * @param key The document key to retrieve.
|
487 | * @param options Optional parameters for this operation.
|
488 | * @param callback A node-style callback to be invoked after execution.
|
489 | */
|
490 | getAllReplicas(key: string, options?: GetAllReplicasOptions, callback?: NodeCallback<GetReplicaResult[]>): Promise<GetReplicaResult[]>;
|
491 | /**
|
492 | * Inserts a new document to the collection, failing if the document already exists.
|
493 | *
|
494 | * @param key The document key to insert.
|
495 | * @param value The value of the document to insert.
|
496 | * @param options Optional parameters for this operation.
|
497 | * @param callback A node-style callback to be invoked after execution.
|
498 | */
|
499 | insert(key: string, value: any, options?: InsertOptions, callback?: NodeCallback<MutationResult>): Promise<MutationResult>;
|
500 | /**
|
501 | * Upserts a document to the collection. This operation succeeds whether or not the
|
502 | * document already exists.
|
503 | *
|
504 | * @param key The document key to upsert.
|
505 | * @param value The new value for the document.
|
506 | * @param options Optional parameters for this operation.
|
507 | * @param callback A node-style callback to be invoked after execution.
|
508 | */
|
509 | upsert(key: string, value: any, options?: UpsertOptions, callback?: NodeCallback<MutationResult>): Promise<MutationResult>;
|
510 | /**
|
511 | * Replaces the value of an existing document. Failing if the document does not exist.
|
512 | *
|
513 | * @param key The document key to replace.
|
514 | * @param value The new value for the document.
|
515 | * @param options Optional parameters for this operation.
|
516 | * @param callback A node-style callback to be invoked after execution.
|
517 | */
|
518 | replace(key: string, value: any, options?: ReplaceOptions, callback?: NodeCallback<MutationResult>): Promise<MutationResult>;
|
519 | /**
|
520 | * Remove an existing document from the collection.
|
521 | *
|
522 | * @param key The document key to remove.
|
523 | * @param options Optional parameters for this operation.
|
524 | * @param callback A node-style callback to be invoked after execution.
|
525 | */
|
526 | remove(key: string, options?: RemoveOptions, callback?: NodeCallback<MutationResult>): Promise<MutationResult>;
|
527 | /**
|
528 | * Retrieves the value of the document and simultanously updates the expiry time
|
529 | * for the same document.
|
530 | *
|
531 | * @param key The document to fetch and touch.
|
532 | * @param expiry The new expiry to apply to the document, specified in seconds.
|
533 | * @param options Optional parameters for this operation.
|
534 | * @param callback A node-style callback to be invoked after execution.
|
535 | */
|
536 | getAndTouch(key: string, expiry: number, options?: GetAndTouchOptions, callback?: NodeCallback<GetResult>): Promise<GetResult>;
|
537 | /**
|
538 | * Updates the expiry on an existing document.
|
539 | *
|
540 | * @param key The document key to touch.
|
541 | * @param expiry The new expiry to set for the document, specified in seconds.
|
542 | * @param options Optional parameters for this operation.
|
543 | * @param callback A node-style callback to be invoked after execution.
|
544 | */
|
545 | touch(key: string, expiry: number, options?: TouchOptions, callback?: NodeCallback<MutationResult>): Promise<MutationResult>;
|
546 | /**
|
547 | * Locks a document and retrieves the value of that document at the time it is locked.
|
548 | *
|
549 | * @param key The document key to retrieve and lock.
|
550 | * @param lockTime The amount of time to lock the document for, specified in seconds.
|
551 | * @param options Optional parameters for this operation.
|
552 | * @param callback A node-style callback to be invoked after execution.
|
553 | */
|
554 | getAndLock(key: string, lockTime: number, options?: GetAndLockOptions, callback?: NodeCallback<GetResult>): Promise<GetResult>;
|
555 | /**
|
556 | * Unlocks a previously locked document.
|
557 | *
|
558 | * @param key The document key to unlock.
|
559 | * @param cas The CAS of the document, used to validate lock ownership.
|
560 | * @param options Optional parameters for this operation.
|
561 | * @param callback A node-style callback to be invoked after execution.
|
562 | */
|
563 | unlock(key: string, cas: CasInput, options?: UnlockOptions, callback?: NodeCallback<void>): Promise<void>;
|
564 | /**
|
565 | * @internal
|
566 | */
|
567 | _continueScan(iterator: CppScanIterator, transcoder: Transcoder, emitter: StreamableScanPromise<ScanResult[], ScanResult>): void;
|
568 | /**
|
569 | * @internal
|
570 | */
|
571 | _doScan(scanType: RangeScan | SamplingScan | PrefixScan, options: CppRangeScanOrchestratorOptions, transcoder: Transcoder, callback?: NodeCallback<ScanResult[]>): StreamableScanPromise<ScanResult[], ScanResult>;
|
572 | /**
|
573 | * Performs a key-value scan operation.
|
574 | *
|
575 | * Use this API for low concurrency batch queries where latency is not a critical as the system
|
576 | * may have to scan a lot of documents to find the matching documents.
|
577 | * For low latency range queries, it is recommended that you use SQL++ with the necessary indexes.
|
578 | *
|
579 | * @param scanType The type of scan to execute.
|
580 | * @param options Optional parameters for the scan operation.
|
581 | * @param callback A node-style callback to be invoked after execution.
|
582 | */
|
583 | scan(scanType: RangeScan | SamplingScan | PrefixScan, options?: ScanOptions, callback?: NodeCallback<ScanResult[]>): Promise<ScanResult[]>;
|
584 | /**
|
585 | * Performs a lookup-in operation against a document, fetching individual fields or
|
586 | * information about specific fields inside the document value.
|
587 | *
|
588 | * @param key The document key to look in.
|
589 | * @param specs A list of specs describing the data to fetch from the document.
|
590 | * @param options Optional parameters for this operation.
|
591 | * @param callback A node-style callback to be invoked after execution.
|
592 | */
|
593 | lookupIn(key: string, specs: LookupInSpec[], options?: LookupInOptions, callback?: NodeCallback<LookupInResult>): Promise<LookupInResult>;
|
594 | /**
|
595 | * @internal
|
596 | */
|
597 | _lookupInReplica(key: string, lookupInAllReplicas: boolean, specs: LookupInSpec[], options?: {
|
598 | timeout?: number;
|
599 | }, callback?: NodeCallback<LookupInReplicaResult[]>): StreamableReplicasPromise<LookupInReplicaResult[], LookupInReplicaResult>;
|
600 | /**
|
601 | * Performs a lookup-in operation against a document, fetching individual fields or
|
602 | * information about specific fields inside the document value from any of the available
|
603 | * replicas in the cluster.
|
604 | *
|
605 | * @param key The document key to look in.
|
606 | * @param specs A list of specs describing the data to fetch from the document.
|
607 | * @param options Optional parameters for this operation.
|
608 | * @param callback A node-style callback to be invoked after execution.
|
609 | */
|
610 | lookupInAnyReplica(key: string, specs: LookupInSpec[], options?: LookupInOptions, callback?: NodeCallback<LookupInReplicaResult>): Promise<LookupInReplicaResult>;
|
611 | /**
|
612 | * Performs a lookup-in operation against a document, fetching individual fields or
|
613 | * information about specific fields inside the document value from all available replicas.
|
614 | * Note that as replication is asynchronous, each node may return a different value.
|
615 | *
|
616 | * @param key The document key to look in.
|
617 | * @param specs A list of specs describing the data to fetch from the document.
|
618 | * @param options Optional parameters for this operation.
|
619 | * @param callback A node-style callback to be invoked after execution.
|
620 | */
|
621 | lookupInAllReplicas(key: string, specs: LookupInSpec[], options?: LookupInOptions, callback?: NodeCallback<LookupInReplicaResult[]>): Promise<LookupInReplicaResult[]>;
|
622 | /**
|
623 | * Performs a mutate-in operation against a document. Allowing atomic modification of
|
624 | * specific fields within a document. Also enables access to document extended-attributes.
|
625 | *
|
626 | * @param key The document key to mutate.
|
627 | * @param specs A list of specs describing the operations to perform on the document.
|
628 | * @param options Optional parameters for this operation.
|
629 | * @param callback A node-style callback to be invoked after execution.
|
630 | */
|
631 | mutateIn(key: string, specs: MutateInSpec[], options?: MutateInOptions, callback?: NodeCallback<MutateInResult>): Promise<MutateInResult>;
|
632 | /**
|
633 | * Returns a CouchbaseList permitting simple list storage in a document.
|
634 | *
|
635 | * @param key The document key the data-structure resides in.
|
636 | */
|
637 | list(key: string): CouchbaseList;
|
638 | /**
|
639 | * Returns a CouchbaseQueue permitting simple queue storage in a document.
|
640 | *
|
641 | * @param key The document key the data-structure resides in.
|
642 | */
|
643 | queue(key: string): CouchbaseQueue;
|
644 | /**
|
645 | * Returns a CouchbaseMap permitting simple map storage in a document.
|
646 | *
|
647 | * @param key The document key the data-structure resides in.
|
648 | */
|
649 | map(key: string): CouchbaseMap;
|
650 | /**
|
651 | * Returns a CouchbaseSet permitting simple set storage in a document.
|
652 | *
|
653 | * @param key The document key the data-structure resides in.
|
654 | */
|
655 | set(key: string): CouchbaseSet;
|
656 | /**
|
657 | * Returns a BinaryCollection object reference, allowing access to various
|
658 | * binary operations possible against a collection.
|
659 | */
|
660 | binary(): BinaryCollection;
|
661 | /**
|
662 | * @internal
|
663 | */
|
664 | _binaryIncrement(key: string, delta: number, options?: IncrementOptions, callback?: NodeCallback<CounterResult>): Promise<CounterResult>;
|
665 | /**
|
666 | * @internal
|
667 | */
|
668 | _binaryDecrement(key: string, delta: number, options?: DecrementOptions, callback?: NodeCallback<CounterResult>): Promise<CounterResult>;
|
669 | /**
|
670 | * @internal
|
671 | */
|
672 | _binaryAppend(key: string, value: string | Buffer, options?: AppendOptions, callback?: NodeCallback<MutationResult>): Promise<MutationResult>;
|
673 | /**
|
674 | * @internal
|
675 | */
|
676 | _binaryPrepend(key: string, value: string | Buffer, options?: PrependOptions, callback?: NodeCallback<MutationResult>): Promise<MutationResult>;
|
677 | /**
|
678 | * Returns a CollectionQueryIndexManager which can be used to manage the query indexes
|
679 | * of this collection.
|
680 | */
|
681 | queryIndexes(): CollectionQueryIndexManager;
|
682 | }
|