forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
couchbase.d.ts
1129 lines (941 loc) · 42.6 KB
/
couchbase.d.ts
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for Couchbase Node.js SDK 2.1.2
// Project: https://github.com/couchbase/couchnode
// Definitions by: Marwan Aouida <https://github.com/maouida>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts"/>
declare module 'couchbase' {
import events = require('events');
/**
* Enumeration of all error codes. See libcouchbase documentation for more details on what these errors represent.
*/
enum errors {
/** Operation was successful. **/
success,
/** Authentication should continue. **/
authContinue,
/** Error authenticating. **/
authError,
/** The passed incr/decr delta was invalid. **/
deltaBadVal,
/** Object is too large to be stored on the cluster. **/
objectTooBig,
/** Operation was successful. **/
serverBusy,
/** Server is too busy to handle your request right now. **/
cLibInternal,
/** An invalid arguement was passed. **/
cLinInvalidArgument,
/** The server is out of memory. **/
cLibOutOfMemory,
/** An invalid range was specified. **/
invalidRange,
/** An unknown error occured within libcouchbase. **/
cLibGenericError,
/** A temporary error occured. Try again. **/
temporaryError,
/** The key already exists on the server. **/
keyAlreadyExists,
/** The key does not exist on the server. **/
keyNotFound,
/** Failed to open library. **/
failedToOpenLibrary,
/** Failed to find expected symbol in library. **/
failedToFindSymbol,
/** A network error occured. **/
networkError,
/** Operations were performed on the incorrect server. **/
wrongServer,
/** Operations were performed on the incorrect server. **/
notMyVBucket,
/** The document was not stored. **/
notSorted,
/** An unsupported operation was sent to the server. **/
notSupported,
/** An unknown command was sent to the server. **/
unknownCommand,
/** An unknown host was specified. **/
unknownHost,
/** A protocol error occured. **/
protocolError,
/** The operation timed out. **/
timedOut,
/** Error connecting to the server. **/
connectError,
/** The bucket you request was not found. **/
bukcketNotFound,
/** libcouchbase is out of memory. **/
clientOutOfMemory,
/** A temporary error occured in libcouchbase. Try again. **/
clientTemporaryError,
/** A bad handle was passed. **/
badHandle,
/** A server bug caused the operation to fail. **/
serverBug,
/** The host format specified is invalid. **/
invalidHostFormat,
/** Not enough nodes to meet the operations durability requirements. **/
notEnoughNodes,
/** Duplicate items. **/
duplicateItems,
/** Key mapping failed and could not match a server. **/
noMatchingServerForKey,
/** A bad environment variable was specified. **/
badEnvironmentVariable,
/** Couchnode is out of memory. **/
outOfMemory,
/** Invalid arguements were passed. **/
invalidArguments,
/** An error occured while trying to schedule the operation. **/
schedulingError,
/** Not all operations completed successfully. **/
checkResults,
/** A generic error occured in Couchnode. **/
genericError,
/** The specified durability requirements could not be satisfied. **/
durabilityFailed,
/** An error occured during a RESTful operation. **/
restError
}
/**
* Represents a singular cluster containing your buckets.
*/
class Cluster {
/**
* Create a new instance of the Cluster class.
* @param cnstr The connection string for your cluster.
* @param options The options object.
*/
constructor(cnstr?: string, options?: ClusterConstructorOptions);
/**
* Creates a manager allowing the management of a Couchbase cluster.
*/
manager(): ClusterManager;
/**
* Open a bucket to perform operations. This will begin the handshake process immediately and operations will complete later. Subscribe to the connect event to be alerted when the connection is ready, though be aware operations can be successfully queued before this.
* @param name The name of the bucket to open.
*/
openBucket(name?: string): Bucket;
/**
* Open a bucket to perform operations. This will begin the handshake process immediately and operations will complete later. Subscribe to the connect event to be alerted when the connection is ready, though be aware operations can be successfully queued before this.
* @param name The name of the bucket to open.
* @param password Password for the bucket.
*/
openBucket(name?: string, password?: string): Bucket;
/**
* Open a bucket to perform operations. This will begin the handshake process immediately and operations will complete later. Subscribe to the connect event to be alerted when the connection is ready, though be aware operations can be successfully queued before this.
* @param name The name of the bucket to open.
* @param callback Callback to invoke on connection success or failure.
*/
openBucket(name?: string, callback?: Function): Bucket;
/**
* Open a bucket to perform operations. This will begin the handshake process immediately and operations will complete later. Subscribe to the connect event to be alerted when the connection is ready, though be aware operations can be successfully queued before this.
* @param name The name of the bucket to open.
* @param password Password for the bucket.
* @param callback Callback to invoke on connection success or failure.
*/
openBucket(name?: string, password?: string, callback?: Function): Bucket;
}
interface ClusterConstructorOptions {
/**
* The path to the certificate to use for SSL connections
*/
certpath: string;
}
interface CreateBucketOptions {
/**
* The bucket name
*/
name?: string;
authType?: string,
bucketType?: string;
ramQuotaMB?: number;
replicaNumber?: number;
}
/**
* Class for performing management operations against a cluster.
*/
interface ClusterManager {
/**
*
* @param name
* @param callback
*/
createBucket(name: string, callback: Function): void;
/**
*
* @param name
* @param opts
* @param callback
*/
createBucket(name: string, opts: any, callback: Function): void;
/**
*
* @param callback
*/
listBuckets(callback: Function): void;
/**
*
* @param name
* @param callback
*/
removeBucket(name: string, callback: Function): void;
}
/**
* The virtual class thrown for all Couchnode errors.
*/
interface CouchbaseError extends Error {
/**
* The error code for this error.
*/
code: errors;
}
interface AppendOptions {
/**
* The CAS value to check. If the item on the server contains a different CAS value, the operation will fail. Note that if this option is undefined, no comparison will be performed.
*/
cas?: Bucket.CAS;
/**
* Ensures this operation is persisted to this many nodes.
*/
persist_to?: number;
/**
* Ensures this operation is replicated to this many nodes.
*/
replicate_to?: number;
}
interface PrependOptions extends AppendOptions { }
interface RemoveOptions extends AppendOptions { }
interface ReplaceOptions extends AppendOptions {
/**
* Set the initial expiration time for the document. A value of 0 represents never expiring.
*/
expiry?: number;
}
interface UpsertOptions extends ReplaceOptions { }
interface TouchOptions {
/**
* Ensures this operation is persisted to this many nodes.
*/
persist_to?: number;
/**
* Ensures this operation is replicated to this many nodes.
*/
replicate_to?: number;
}
interface CounterOptions {
/**
* Sets the initial value for the document if it does not exist. Specifying a value of undefined will cause the operation to fail if the document does not exist, otherwise this value must be equal to or greater than 0.
*/
initial?: number;
/**
* Set the initial expiration time for the document. A value of 0 represents never expiring.
*/
expiry?: number;
/**
* Ensures this operation is persisted to this many nodes
*/
persist_to?: number;
/**
* Ensures this operation is replicated to this many nodes
*/
replicate_to?: number;
}
interface GetAndLockOptions {
lockTime?: number;
}
interface GetReplicaOptions {
/**
* The index for which replica you wish to retrieve this value from, or if undefined, use the value from the first server that replies.
*/
index?: number;
}
interface InsertOptions {
/**
* Set the initial expiration time for the document. A value of 0 represents never expiring.
*/
expiry?: number;
/**
* Ensures this operation is persisted to this many nodes.
*/
persist_to?: number;
/**
* Ensures this operation is replicated to this many nodes.
*/
replicate_to?: number;
}
/**
* A class for performing management operations against a bucket. This class should not be instantiated directly, but instead through the use of the Bucket#manager method instead.
*/
interface BucketManager {
/**
* Flushes the cluster, deleting all data stored within this bucket. Note that this method requires the Flush permission to be enabled on the bucket from the management console before it will work.
* @param callback The callback function.
*/
flush(callback: Function): void;
/**
* Retrieves a specific design document from this bucket.
* @param name
* @param callback The callback function.
*/
getDesignDocument(name: string, callback: Function): void;
/**
* Retrieves a list of all design documents registered to a bucket.
* @param callback The callback function.
*/
getDesignDocuments(callback: Function): void;
/**
* Registers a design document to this bucket, failing if it already exists.
* @param name
* @param data
* @param callback The callback function.
* @returns {}
*/
insertDesignDocument(name: string, data: any, callback: Function): void;
/**
* Unregisters a design document from this bucket.
* @param name
* @param callback The callback function.
* @returns {}
*/
removeDesignDocument(name: string, callback: Function): void;
/**
* Registers a design document to this bucket, overwriting any existing design document that was previously registered.
* @param name
* @param data
* @param callback The callback function.
* @returns {}
*/
upsertDesignDocument(name: string, data: any, callback: Function): void;
}
/**
* Class for dynamically construction of view queries. This class should never be constructed directly, instead you should use ViewQuery.from to construct this object.
*/
class ViewQuery {
/**
* Instantiates a ViewQuery object for the specified design document and view name.
* @param ddoc The design document to use.
* @param name The view to use.
*/
static from(ddoc: string, name: string): ViewQuery;
/**
* Specifies the design document and view name to use for this query.
* @param ddoc The design document to use.
* @param name The view to use.
*/
from(ddoc: string, name: string): ViewQuery;
/**
* Allows you to specify custom view options that may not be available though the fluent interface defined by this class.
* @param opts
*/
custom(opts: any): ViewQuery;
/**
* Flag to request a view request accross all nodes in the case of a development view.
* @param full_set
*/
full_set(full_set: boolean): ViewQuery;
/**
* Specifies whether to preform grouping during view execution.
* @param group
*/
group(group: boolean): ViewQuery;
/**
* Specifies the level at which to perform view grouping.
* @param group_level
*/
group_level(group_level: number): ViewQuery;
/**
* Specifies a range of document id's to retrieve from the index.
* @param start
* @param end
*/
id_range(start: any, end: any): ViewQuery;
/**
* Flag to request a view request include the full document value.
* @param include_docs
*/
include_docs(include_docs: boolean): ViewQuery;
/**
* Specifies a specified key to retrieve from the index.
* @param key
*/
key(key: any): ViewQuery;
/**
* Specifies a list of keys you wish to retrieve from the index.
* @param keys
*/
keys(key: any[]): ViewQuery;
/**
* Specifies the maximum number of results to return.
* @param limit
*/
limit(limit: number): ViewQuery;
/**
* Sets the error handling mode for this query.
* @param mode
*/
on_error(mode: ViewQuery.ErrorMode): ViewQuery;
/**
* Specifies the desired ordering for the results.
* @param order
*/
order(order: ViewQuery.Order): ViewQuery;
/**
* Specifies a range of keys to retrieve from the index. You may specify both a start and an end point and additionally specify whether or not the end value is inclusive or exclusive.
* @param start
* @param end
* @param inclusive_end
*/
range(start: any | any[], end: any | any[], inclusive_end?: boolean): ViewQuery;
/**
* Specifies whether to execute the map-reduce reduce step.
* @param reduce
*/
reduce(reduce: boolean): ViewQuery;
/**
* Specifies how many results to skip from the beginning of the result set.
* @param skip
*/
skip(skip: number): ViewQuery;
/**
* Specifies how this query will affect view indexing, both before and after the query is executed.
* @param stale
*/
stale(stale: ViewQuery.Update): ViewQuery;
}
namespace ViewQuery {
/**
* Enumeration for specifying on_error behaviour.
*/
enum ErrorMode {
/**
* Continues querying when an error occurs.
*/
CONTINUE,
/**
* Stops and errors query when an error occurs.
*/
STOP
}
/**
* Enumeration for specifying view result ordering.
*/
enum Order {
/**
* Orders with lower values first and higher values last.
*/
ASCENDING,
/**
* Orders with higher values first and lower values last.
*/
DESCENDING
}
/**
* Enumeration for specifying view update semantics.
*/
enum Update {
/**
* Causes the view to be fully indexed before results are retrieved.
*/
BEFORE,
/**
* Allows the index to stay in whatever state it is already in prior retrieval of the query results.
*/
NONE,
/**
* Forces the view to be indexed after the results of this query has been fetched.
*/
AFTER
}
}
/**
* Class for dynamically construction of N1QL queries. This class should never be constructed directly, instead you should use the N1qlQuery.fromString static method to instantiate a N1qlStringQuery.
*/
class N1qlQuery {
/**
* Creates a query object directly from the passed query string.
* @param str
*/
static fromString(str: string): N1qlStringQuery;
/**
* Returns the fully prepared string representation of this query.
*/
toString(): string;
}
namespace N1qlQuery {
/**
* Enumeration for specifying N1QL consistency semantics.
*/
enum Consistency {
/**
* This is the default (for single-statement requests).
*/
NOT_BOUND,
/**
* This implements strong consistency per request.
*/
REQUEST_PLUS,
/**
* This implements strong consistency per statement.
*/
STATEMENT_PLUS
}
}
/**
* Class for holding a explicitly defined N1QL query string.
*/
class N1qlStringQuery extends N1qlQuery {
/**
* Specifies whether this query is adhoc or should be prepared.
* @param adhoc
*/
adhoc(adhoc: boolean): N1qlStringQuery;
/**
* Specify the consistency level for this query.
* @param val
*/
consistency(val: N1qlQuery.Consistency): N1qlStringQuery;
/**
* Returns the fully prepared object representation of this query.
*/
toObject(): any;
/**
* Returns the fully prepared string representation of this query.
*/
toString(): string;
}
/**
* Class for dynamically construction of spatial queries. This class should never be constructed directly, instead you should use SpatialQuery.from to construct this object.
*/
class SpatialQuery {
/**
* Instantiates a SpatialQuery object for the specified design document and view name.
* @param ddoc The design document to use.
* @param name The view to use.
*/
static from(ddoc: string, name: string): SpatialQuery;
/**
* Specifies the design document and view name to use for this query.
* @param ddoc
* @param name
*/
from(ddoc: string, name: string): SpatialQuery;
/**
* Specifies a bounding box to query the index for. This value must be an array of exactly 4 numbers which represents the left, top, right and bottom edges of the bounding box (in that order).
* @param bbox
*/
bbox(bbox: number[]): SpatialQuery;
/**
* Allows you to specify custom view options that may not be available though the fluent interface defined by this class.
* @param opts
*/
custom(opts: any): SpatialQuery;
/**
* Specifies the maximum number of results to return.
* @param limit
*/
limit(limit: number): SpatialQuery;
/**
* Specifies how many results to skip from the beginning of the result set.
* @param skip
*/
skip(skip: number): SpatialQuery;
/**
* Specifies how this query will affect view indexing, both before and after the query is executed.
* @param stale
*/
stale(stale: SpatialQuery.Update): SpatialQuery;
}
namespace SpatialQuery {
/**
* Enumeration for specifying view update semantics.
*/
enum Update {
/**
* Causes the view to be fully indexed before results are retrieved.
*/
BEFORE,
/**
* Allows the index to stay in whatever state it is already in prior retrieval of the query results.
*/
NONE,
/**
* Forces the view to be indexed after the results of this query has been fetched.
*/
AFTER
}
}
/**
* The Bucket class represents a connection to a Couchbase bucket. Never instantiate this class directly. Instead use the Cluster#openBucket method instead.
*/
interface Bucket {
/**
* Returns the version of the Node.js library as a string.
*/
clientVersion: string;
/**
* Gets or sets the config throttling in milliseconds. The config throttling is the time that Bucket will wait before forcing a configuration refresh. If no refresh occurs before this period while a configuration is marked invalid, an update will be triggered.
*/
configThrottle: number;
/**
* Sets or gets the connection timeout in milliseconds. This is the timeout value used when connecting to the configuration port during the initial connection (in this case, use this as a key in the 'options' parameter in the constructor) and/or when Bucket attempts to reconnect in-situ (if the current connection has failed).
*/
connectionTimeout: number;
/**
* Gets or sets the durability interval in milliseconds. The durability interval is the time that Bucket will wait between requesting new durability information during a durability poll.
*/
durabilityInterval: number;
/**
* Gets or sets the durability timeout in milliseconds. The durability timeout is the time that Bucket will wait for a response from the server in regards to a durability request. If there are no responses received within this time frame, the request fails with an error.
*/
durabilityTimeout: number;
/**
* Returns the libcouchbase version as a string. This information will usually be in the format of 2.4.0-fffffff representing the major, minor, patch and git-commit that the built libcouchbase is based upon.
*/
lcbVersion: string;
/**
* Gets or sets the management timeout in milliseconds. The management timeout is the time that Bucket will wait for a response from the server for a management request. If the response is not received within this time frame, the request is failed out with an error.
*/
managementTimeout: number;
/**
* Sets or gets the node connection timeout in msecs. This value is similar to Bucket#connectionTimeout, but defines the time to wait for a particular node to respond before trying the next one.
*/
nodeConnectionTimeout: number;
/**
* Gets or sets the operation timeout in milliseconds. The operation timeout is the time that Bucket will wait for a response from the server for a CRUD operation. If the response is not received within this time frame, the operation is failed with an error.
*/
operationTimeout: number;
/**
* Gets or sets the view timeout in milliseconds. The view timeout is the time that Bucket will wait for a response from the server for a view request. If the response is not received within this time frame, the request fails with an error.
*/
viewTimeout: number;
/**
* Similar to Bucket#upsert, but instead of setting a new key, it appends data to the existing key. Note that this function only makes sense when the stored data is a string; 'appending' to a JSON document may result in parse errors when the document is later retrieved.
* @param key The target document key.
* @param fragment The document's contents to append.
* @param callback The callback function.
*/
append(key: any | Buffer, fragment: any, callback: Bucket.OpCallback): void;
/**
*
* @param key The target document key.
* @param fragment The document's contents to append.
* @param options The options object.
* @param callback The callback function.
*/
append(key: any | Buffer, fragment: any, options: AppendOptions, callback: Bucket.OpCallback): void;
/**
* Increments or decrements a key's numeric value.
* Note that JavaScript does not support 64-bit integers (while libcouchbase and the server do). You might receive an inaccurate value if the number is greater than 53-bits (JavaScript's maximum integer precision).
* @param key The target document key.
* @param delta The amount to add or subtract from the counter value. This value may be any non-zero integer.
* @param callback The callback function.
*/
counter(key: any | Buffer, delta: number, callback: Bucket.OpCallback): void;
/**
*
* @param key The target document key.
* @param delta The amount to add or subtract from the counter value. This value may be any non-zero integer.
* @param options The options object.
* @param callback The callback function.
*/
counter(key: any | Buffer, delta: number, options: CounterOptions, callback: Bucket.OpCallback): void;
/**
* Shuts down this connection.
*/
disconnect(): void;
/**
* Enables N1QL support on the client. A cbq-server URI must be passed. This method will be deprecated in the future in favor of automatic configuration through the connected cluster.
* @param hosts An array of host/port combinations which are N1QL servers attached to this cluster.
*/
enableN1ql(hosts: string | string[]): void;
/**
* Retrieves a document.
* @param key The target document key.
* @param callback The callback function.
*/
get(key: any | Buffer, callback: Bucket.OpCallback): void;
/**
* @param key The target document key.
* @param options The options object.
* @param callback The callback function.
*/
get(key: any | Buffer, options: any, callback: Bucket.OpCallback): void;
/**
* Lock the document on the server and retrieve it. When an document is locked, its CAS changes and subsequent operations on the document (without providing the current CAS) will fail until the lock is no longer held.
* This function behaves identically to Bucket#get in that it will return the value. It differs in that the document is also locked. This ensures that attempts by other client instances to access this document while the lock is held will fail.
* Once locked, a document can be unlocked either by explicitly calling Bucket#unlock or by performing a storage operation (e.g. Bucket#upsert, Bucket#replace, Bucket::append) with the current CAS value. Note that any other lock operations on this key will fail while a document is locked.
* @param key The target document key.
* @param callback The callback function.
*/
getAndLock(key: any, callback: Bucket.OpCallback): void;
/**
* Lock the document on the server and retrieve it. When an document is locked, its CAS changes and subsequent operations on the document (without providing the current CAS) will fail until the lock is no longer held.
* This function behaves identically to Bucket#get in that it will return the value. It differs in that the document is also locked. This ensures that attempts by other client instances to access this document while the lock is held will fail.
* Once locked, a document can be unlocked either by explicitly calling Bucket#unlock or by performing a storage operation (e.g. Bucket#upsert, Bucket#replace, Bucket::append) with the current CAS value. Note that any other lock operations on this key will fail while a document is locked.
* @param key The target document key.
* @param options The options object.
* @param callback The callback function.
* @returns {}
*/
getAndLock(key: any, options: GetAndLockOptions, callback: Bucket.OpCallback): void;
/**
* Retrieves a document and updates the expiry of the item at the same time.
* @param key The target document key.
* @param expiry The expiration time to use. If a value of 0 is provided, then the current expiration time is cleared and the key is set to never expire. Otherwise, the key is updated to expire in the time provided (in seconds).
* @param options The options object.
* @param callback The callback function.
*/
getAndTouch(key: any | Buffer, expiry: number, options: any, callback: Bucket.OpCallback): void;
/**
* Retrieves a document and updates the expiry of the item at the same time.
* @param key The target document key.
* @param expiry The expiration time to use. If a value of 0 is provided, then the current expiration time is cleared and the key is set to never expire. Otherwise, the key is updated to expire in the time provided (in seconds).
* @param callback The callback function.
*/
getAndTouch(key: any | Buffer, expiry: number, callback: Bucket.OpCallback): void;
/**
* Retrieves a list of keys
* @param keys The target document keys.
* @param callback The callback function.
*/
getMulti(key: any[] | Buffer[], callback: Bucket.MultiGetCallback): void;
/**
* Get a document from a replica server in your cluster.
* @param key The target document key.
* @param callback The callback function.
*/
getReplica(key: any | Buffer, callback: Bucket.OpCallback): void;
/**
* Get a document from a replica server in your cluster.
* @param key The target document key.
* @param options The options object.
* @param callback The callback function.
*/
getReplica(key: any | Buffer, options: GetReplicaOptions, callback: Bucket.OpCallback): void;
/**
* Identical to Bucket#upsert but will fail if the document already exists.
* @param key The target document key.
* @param value The document's contents.
* @param callback The callback function.
*/
insert(key: any | Buffer, value: any, callback: Bucket.OpCallback): void;
/**
* Identical to Bucket#upsert but will fail if the document already exists.
* @param key The target document key.
* @param value The document's contents.
* @param options The options object.
* @param callback The callback function.
*/
insert(key: any | Buffer, value: any, options: InsertOptions, callback: Bucket.OpCallback): void;
/**
* Returns an instance of a BuckerManager for performing management operations against a bucket.
*/
manager(): BucketManager;
/**
* Like Bucket#append, but prepends data to the existing value.
* @param key The target document key.
* @param fragment The document's contents to prepend.
* @param callback The callback function.
*/
prepend(key: any, fragment: any, callback: Bucket.OpCallback): void;
/**
* Like Bucket#append, but prepends data to the existing value.
* @param key The target document key.
* @param fragment The document's contents to prepend.
* @param options The options object.
* @param callback The callback function.
*/
prepend(key: any, fragment: any, options: PrependOptions, callback: Bucket.OpCallback): void;
/**
* Executes a previously prepared query object. This could be a ViewQuery or a N1qlQuery.
* Note: N1qlQuery queries are currently an uncommitted interface and may be subject to change in 2.0.0's final release.
* @param query The query to execute.
* @param callback The callback function.
*/
query(query: ViewQuery | N1qlQuery, callback: Bucket.QueryCallback): Bucket.ViewQueryResponse | Bucket.N1qlQueryResponse;
/**
* Executes a previously prepared query object. This could be a ViewQuery or a N1qlQuery.
* Note: N1qlQuery queries are currently an uncommitted interface and may be subject to change in 2.0.0's final release.
* @param query The query to execute.
* @param params A list or map to do replacements on a N1QL query.
* @param callback The callback function.
*/
query(query: ViewQuery | N1qlQuery, params: Object | Array<any>, callback: Bucket.QueryCallback): Bucket.ViewQueryResponse | Bucket.N1qlQueryResponse;
/**
* Deletes a document on the server.
* @param key The target document key.
* @param callback The callback function.
*/
remove(key: any | Buffer, callback: Bucket.OpCallback): void;
/**
* Deletes a document on the server.
* @param key The target document key.
* @param options The options object.
* @param callback The callback function.
*/
remove(key: any | Buffer, options: RemoveOptions, callback: Bucket.OpCallback): void;
/**
* Identical to Bucket#upsert, but will only succeed if the document exists already (i.e. the inverse of Bucket#insert).
* @param key The target document key.
* @param value The document's contents.
* @param callback The callback function.
*/
replace(key: any | Buffer, value: any, callback: Bucket.OpCallback): void;
/**
* Identical to Bucket#upsert, but will only succeed if the document exists already (i.e. the inverse of Bucket#insert).
* @param key The target document key.
* @param value The document's contents.
* @param options The options object.
* @param callback The callback function.
*/
replace(key: any | Buffer, value: any, options: ReplaceOptions, callback: Bucket.OpCallback): void;
/**
* Configures a custom set of transcoder functions for encoding and decoding values that are being stored or retreived from the server.
* @param encoder The function for encoding.
* @param decoder The function for decoding.
*/
setTranscoder(encoder: Bucket.EncoderFunction, decoder: Bucket.DecoderFunction): void;
/**
* Update the document expiration time.
* @param key The target document key.
* @param expiry The expiration time to use. If a value of 0 is provided, then the current expiration time is cleared and the key is set to never expire. Otherwise, the key is updated to expire in the time provided (in seconds). Values larger than 302460*60 seconds (30 days) are interpreted as absolute times (from the epoch).
* @param options The options object.
* @param callback The callback function.
*/
touch(key: any | Buffer, expiry: number, options: TouchOptions, callback: Bucket.OpCallback): void;
/**
* Unlock a previously locked document on the server. See the Bucket#lock method for more details on locking.
* @param key The target document key.
* @param cas The CAS value returned when the key was locked. This operation will fail if the CAS value provided does not match that which was the result of the original lock operation.
* @param callback The callback function.
*/
unlock(key: any | Buffer, cas: Bucket.CAS, callback: Bucket.OpCallback): void;
/**
* Unlock a previously locked document on the server. See the Bucket#lock method for more details on locking.
* @param key The target document key.
* @param cas The CAS value returned when the key was locked. This operation will fail if the CAS value provided does not match that which was the result of the original lock operation.
* @param options The options object.
* @param callback The callback function.
*/
unlock(key: any | Buffer, cas: Bucket.CAS, options: any, callback: Bucket.OpCallback): void;
/**
* Stores a document to the bucket.
* @param key The target document key.
* @param value The document's contents.
* @param callback The callback function.
*/
upsert(key: any | Buffer, value: any, callback: Bucket.OpCallback): void;