fixed build errors + removed old version definition

This commit is contained in:
Marwan Aouida
2015-12-31 08:39:01 +01:00
parent c0049815d6
commit 11b4d3ab95
3 changed files with 64 additions and 803 deletions

View File

@@ -1,21 +0,0 @@
/// <reference path="couchbase.d.ts"/>
import couchbase = require('couchbase');
var db = new couchbase.Connection({ bucket: "default" }, function (err) {
if (err) throw err;
// TS 0.9.5 bug https://typescript.codeplex.com/workitem/2035, todo: remove cast after fix
(<couchbase.Connection>db).set('testdoc', { name: 'Frank' }, function (err, result) {
if (err) throw err;
var s: string = err.message;
// TS 0.9.5 bug https://typescript.codeplex.com/workitem/2035, todo: remove cast after fix
(<couchbase.Connection>db).get('testdoc', function (err, result) {
if (err) throw err;
console.log(result.value);
// {name: Frank}
});
});
});

View File

@@ -1,729 +0,0 @@
// Type definitions for Couchbase Couchnode
// Project: https://github.com/couchbase/couchnode
// Definitions by: Basarat Ali Syed <https://github.com/basarat>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts"/>
declare module 'couchbase' {
/**
* Enumeration of all error codes. See libcouchbase documentation
* for more details on what these errors represent.
*
* @global
* @readonly
* @enum {number}
*/
export var errors: {
/** Operation was successful **/
success: number;
/** Authentication should continue. **/
authContinue: number;
/** Error authenticating. **/
authError: number;
/** The passed incr/decr delta was invalid. **/
deltaBadVal: number;
/** Object is too large to be stored on the cluster. **/
objectTooBig: number;
/** Server is too busy to handle your request right now. **/
serverBusy: number;
/** Internal libcouchbase error. **/
cLibInternal: number;
/** An invalid arguement was passed. **/
cLibInvalidArgument: number;
/** The server is out of memory. **/
cLibOutOfMemory: number;
/** An invalid range was specified. **/
invalidRange: number;
/** An unknown error occured within libcouchbase. **/
cLibGenericError: number;
/** A temporary error occured. Try again. **/
temporaryError: number;
/** The key already exists on the server. **/
keyAlreadyExists: number;
/** The key does not exist on the server. **/
keyNotFound: number;
/** Failed to open library. **/
failedToOpenLibrary: number;
/** Failed to find expected symbol in library. **/
failedToFindSymbol: number;
/** A network error occured. **/
networkError: number;
/** Operations were performed on the incorrect server. **/
wrongServer: number;
/** Operations were performed on the incorrect server. **/
notMyVBucket: number;
/** The document was not stored. */
notStored: number;
/** An unsupported operation was sent to the server. **/
notSupported: number;
/** An unknown command was sent to the server. **/
unknownCommand: number;
/** An unknown host was specified. **/
unknownHost: number;
/** A protocol error occured. **/
protocolError: number;
/** The operation timed out. **/
timedOut: number;
/** Error connecting to the server. **/
connectError: number;
/** The bucket you request was not found. **/
bucketNotFound: number;
/** libcouchbase is out of memory. **/
clientOutOfMemory: number;
/** A temporary error occured in libcouchbase. Try again. **/
clientTemporaryError: number;
/** A bad handle was passed. */
badHandle: number;
/** A server bug caused the operation to fail. **/
serverBug: number;
/** The host format specified is invalid. **/
invalidHostFormat: number;
/** Not enough nodes to meet the operations durability requirements. **/
notEnoughNodes: number;
/** Duplicate items. **/
duplicateItems: number;
/** Key mapping failed and could not match a server. **/
noMatchingServerForKey: number;
/** A bad environment variable was specified. **/
badEnvironmentVariable: number;
/** Couchnode is out of memory. **/
outOfMemory: number;
/** Invalid arguements were passed. **/
invalidArguments: number;
/** An error occured while trying to schedule the operation. **/
schedulingError: number;
/** Not all operations completed successfully. **/
checkResults: number;
/** A generic error occured in Couchnode. **/
genericError: number;
/** The specified durability requirements could not be satisfied. **/
durabilityFailed: number;
/** An error occured during a RESTful operation. **/
restError: number;
}
/**
* Enumeration of all value encoding formats.
*
* @global
* @readonly
* @enum {number}
*/
export var format: {
/** Store as raw bytes. **/
raw: number;
/** Store as JSON encoded string. **/
json: number;
/** Store as UTF-8 encoded string. **/
utf8: number;
/** Automatically determine best storage format. **/
auto: number;
};
/**
* The *CAS* value is a special object which indicates the current state
* of the item on the server. Each time an object is mutated on the server, the
* value is changed. <i>CAS</i> objects can be used in conjunction with
* mutation operations to ensure that the value on the server matches the local
* value retrieved by the client. This is useful when doing document updates
* on the server as you can ensure no changes were applied by other clients
* while you were in the process of mutating the document locally.
*
* In Couchnode, this is an opaque value. As such, you cannot generate
* <i>CAS</i> objects, but should rather use the values returned from a
* {@link KeyCallback}.
*
* @typedef {object} CAS
*/
export interface CAS extends Object {
}
/**
* @class Result
* @classdesc
* The virtual class used for results of various operations.
* @private
*/
export class Result {
/**
* The CAS value for the document that was affected by the operation.
* @var {CAS} Result#cas
*/
cas: CAS;
/**
* The flags associate with the document.
* @var {integer} Result#flags
*/
flags: number;
/**
* The resulting document from the retrieval operation that was executed.
* @var {Mixed} Result#value
*/
value: any;
}
/**
* @class CouchbaseError
* @classdesc
* The virtual class thrown for all Couchnode errors.
* @private
* @extends node#Error
*/
export interface CouchbaseError extends Error {
/**
* The error code for this error.
* @var {errors} Error#code
*/
code: number;
/**
* The internal error that occured to cause this one. This is used to wrap
* low-level errors before throwing them from couchnode to simplify error
* handling.
* @var {(node#Error)} Error#innerError
*/
innerError: Error;
/**
* A reason string describing the reason this error occured. This value is
* almost exclusively used for REST request errors.
* @var {string} Error#reason
*/
reason: string;
}
/**
* Connect callback
* This callback is invoked when a connection is successfully established.
*
* @typedef {function} ConnectCallback
*
* @param {undefined|Error} error
* The error that occurred while trying to connect to the cluster.
*/
export interface ConnectCallback {
(error: CouchbaseError): any;
}
/**
* Design Document Management callbacks
* This callback is invoked by the *DesignDoc operations.
*
* @typedef {function} DDocCallback
*
* @param {undefined|Error} error
* An error indicator. Note that this error value may be ignored, but its
* absence is indicative that the response in the *result* parameter is ok.
* If it is set, then the request likely failed.
* @param {object} result
* The result returned from the server
*/
export interface DDocCallback {
(error: CouchbaseError, result: any): any;
}
/**
* Single-Key callbacks.
* This callback is passed to all of the single key functions.
*
* A typical use pattern is to pass the <i>result></i> parameter from the
* callback as the <i>options</i> parameter to one of the next operations.
*
* @typedef {function} KeyCallback
*
* @param {undefined|Error} error
* The error for the operation. This can either be an Error object
* or a false value. The error contains the following fields:
* @param {Result} result
* The result of the operation that was executed.
*/
export interface KeyCallback {
(error: CouchbaseError, result: Result): any;
}
/**
* Multi-Key callbacks
* This callback is invoked by the *Multi operations.
* It differs from the in {@linkcode KeyCallback} that the
* <i>response</i> object is an object of <code>{key: response}</code>
* where each response object contains the response for that particular
* key.
*
* @typedef {function} MultiCallback
*
* @param {undefined|Error} error
* An error indicator. Note that this error
* value may be ignored, but its absence is indicative that each
* response in the <code>results</code> parameter is ok. If it
* is set, then at least one of the result objects failed
* @param {Object.<string,Result>} results
* The results of the operation as a dictionary of keys mapped to Result
* objects.
*/
export interface MultiCallback {
(error: CouchbaseError, result: { [key: string]: Result }): any;
}
/**
* Query callback.
* This callback is invoked by the query operations.
*
* @typedef {function} QueryCallback
*
* @param {undefined|Error} error
* An error indicator. Note that this error
* value may be ignored, but its absence is indicative that the
* response in the <code>results</code> parameter is ok. If it
* is set, then the request failed.
* @param {object} results
* The results returned from the server
*/
export interface QueryCallback {
(error: CouchbaseError, result: any): any;
}
/**
* @typedef {function} StatsCallback
*
* @param {Error} error
* @param {Object.<string,Object>} results
* An object containing per-server, per key entries
*
* @see Connection#stats
*/
export interface StatsCallback {
(error: CouchbaseError, result: any): any;
}
/////////////////////////
// Various options structures
/////////////////////////
export interface ConnectionOptions {
host?: any; // string | string[]
bucket?: string;
password?: string;
}
// Not comming up with a base interface system as that is not how the original code is written.
// Use a custom base interface system has the potential to become difficult to keep up to date.
export interface AddOptions {
expiry?: number;
flags?: number;
format?: number
persist_to?: number;
replicate_to?: number;
}
export interface AddMultiOptionsForValue {
value: any;
expiry?: number;
flags?: number;
format?: number;
}
export interface AddMultiOptions {
expiry?: number;
flags?: number;
format?: number
persist_to?: number;
replicate_to?: number;
spooled?: boolean;
}
export interface AppendOptions {
expiry?: number;
flags?: number;
format?: number;
persist_to?: number;
replicate_to?: number;
cas: CAS;
}
export interface AppendMultiOptionsForValue {
value: any;
cas?: CAS;
expiry?: number;
}
export interface AppendMultiOptions {
expiry?: number;
persist_to?: number;
replicate_to?: number;
spooled?: boolean;
}
export interface DecrOptions {
offset?: number;
initial?: number;
expiry?: number;
persist_to?: number;
replicate_to?: number;
}
export interface DecrMultiOptionsForValue {
offset?: number;
initial?: number;
expiry?: number;
}
export interface DecrMultiOptions {
spooled?: boolean;
}
export interface GetOptions {
expiry?: number;
format?: number;
}
export interface GetMultiOptions {
spooled?: boolean;
format?: number;
}
export interface GetReplicaOptions {
index?: number;
format?: number;
}
export interface GetReplicaMultiOptions {
spooled?: boolean;
format?: number;
}
export interface IncrOptions extends DecrOptions { }
export interface IncrMultiOptionsForValue extends DecrMultiOptionsForValue { }
export interface IncrMultiOptions extends DecrMultiOptions { }
export interface LockOptions {
lockTime?: number
}
export interface LockMultiOptions {
spooled?: boolean;
format?: number;
}
export interface ObserveOptions {
cas: CAS; // verified not optional
}
export interface ObserveMultiOptionsForValue {
cas: CAS; // verified not optional
}
export interface ObserveMultiOptions {
spooled?: boolean;
}
export interface PrependOptions {
expiry?: number;
flags?: number;
format?: number;
persist_to?: number;
replicate_to?: number;
cas?: CAS;
}
export interface PrependMultiOptionsFoValue {
value: any;
cas: CAS;
expiry?: number;
}
export interface PrependMultiOptions {
spooled?: boolean;
expiry?: number;
persist_to?: number;
replicate_to?: number;
}
export interface RemoveOptions {
cas?: CAS;
persist_to?: number;
replicate_to?: number;
}
export interface RemoveMultiOptionsForValue {
cas?: CAS;
}
export interface RemoveMultiOptions {
spooled?: boolean;
persist_to?: number;
replicate_to?: number;
}
// Options for Replace functions follow Set Options and this is mentioned explicitly in the documentation
export interface ReplaceOptions extends SetOptions { }
export interface ReplaceMultiOptionsForValue extends SetMultiOptionsForValue { }
export interface ReplaceMultiOptions extends SetMultiOptions { }
export interface SetOptions {
expiry?: number;
flags?: number;
format?: number;
persist_to?: number;
replicate_to?: number;
cas?: CAS;
}
export interface SetMultiOptionsForValue {
value: any;
cas?: CAS;
expiry?: number;
flags?: number;
format?: number;
}
export interface SetMultiOptions {
expiry?: number;
flags?: number;
format?: number
persist_to?: number;
replicate_to?: number;
spooled?: boolean;
}
export interface TouchOptions {
expiry?: number;
persist_to?: number;
replicate_to?: number;
cas?: CAS;
}
export interface UnlockOptions {
cas: CAS; // verified not optional
}
export interface UnlockMultiOptionsForValue {
cas: CAS; // verified not optional
}
export interface UnlockMultiOptions {
spooled?: boolean;
}
/**
* @class
* A class representing a connection to a Couchbase cluster.
* Normally, your application should only need to create one of these per
* bucket and use it continuously. Operations are executed asynchronously
* and pipelined when possible.
*
* @desc
* Instantiate a new Connection object. Note that it is safe to perform
* operations before the connect callback is invoked. In this case, the
* operations are queued until the connection is ready (or an unrecoverable
* error has taken place).
*
* @param {Object} [options]
* A dictionary of options to use. You may pass
* other options than those defined below which correspond to the various
* options available on the Connection object (see their documentation).
* For example, it may be helpful to set timeout properties before connecting.
* @param {string|string[]} [options.host="localhost:8091"]
* A string or array of strings indicating the hosts to connect to. If the
* value is an array, all the hosts in the array will be tried until one of
* them succeeds.
* @param {string} [options.bucket="default"]
* The bucket to connect to. If not specified, the default is
* 'default'.
* @param {string} [options.password=""]
* The password for a password protected bucket.
* @param {ConnectCallback} callback
* A callback that will be invoked when the instance has completed connecting
* to the server. Note that this isn't required - however if the connection
* fails, an exception will be thrown if the callback is not provided.
*
* @example
* var couchbase = require('couchbase');
* var db = new couchbase.Connection({}, function(err) {
* if (err) {
* console.log('Connection Error', err);
* } else {
* console.log('Connected!');
* }
* });
*/
export class Connection {
constructor(callback: ConnectCallback);
constructor(options: ConnectionOptions, callback: ConnectCallback);
/////////////////////////
// Members
/////////////////////////
/**
* Get information about the Couchnode version (i.e. this library) as an array
* of [versionNumber, versionString].
*
* @member {Mixed[]} Connection#clientVersion
*/
clientVersion: any[];
connectionTimeout: number;
lcbVersion: any[];
operationTimeout: number;
serverNodes: string[];
/////////////////////////
// Methods
/////////////////////////
// TODO: not sure if these methods return void. Docmentation mentions nothing.
// TODO: For "multi" key methods the documentation says callback can be either KeyCallback | MultiCallback. Sticking with MultiCallback.
// TODO: Verify that kv is not a key value and indeed is string[] e.g. getMulti , getReplicaMulti, lockMulti
add(key: string, value: any, callback: KeyCallback): void;
add(key: string, value: any, options: AddOptions, callback: KeyCallback): void;
addMulti(kv: { [key: string]: AddMultiOptionsForValue }, options: AddMultiOptions, callback: MultiCallback): void;
append(key: string, fragment: string, callback: KeyCallback): void;
append(key: string, fragment: string, options: AppendOptions, callback: KeyCallback): void;
append(key: string, fragment: Buffer, callback: KeyCallback): void;
append(key: string, fragment: Buffer, options: AppendOptions, callback: KeyCallback): void;
appendMulti(kv: { [key: string]: AppendMultiOptionsForValue }, options: AppendMultiOptions, callback: MultiCallback): void;
decr(key: string, callback: KeyCallback): void;
decr(key: string, options: DecrOptions, callback: KeyCallback): void;
decrMulti(kv: { [key: string]: DecrMultiOptionsForValue }, options: DecrMultiOptions, callback: MultiCallback): void;
get(key: string, callback: KeyCallback): void;
get(key: string, options: GetOptions, callback: KeyCallback): void;
getMulti(kv: string[], options: { [key: string]: GetMultiOptions }, callback:MultiCallback): void;
getDesignDoc(name: string, callback: DDocCallback): void;
getReplica(key: string, callback: KeyCallback): void;
getReplica(key: string, options: GetReplicaOptions, callback: KeyCallback): void;
getReplicaMulti(kv: string[], options: GetReplicaMultiOptions, callback: MultiCallback): void;
incr(key: string, callback: KeyCallback): void;
incr(key: string, options: IncrOptions, callback: KeyCallback): void;
incrMulti(kv: { [key: string]: IncrMultiOptionsForValue }, options: IncrMultiOptions, callback: MultiCallback): void;
lock(key: string, callback: KeyCallback): void;
lock(key: string, options: LockOptions, callback: KeyCallback): void;
lockMulti(kv: string[], options: { [key: string]: LockMultiOptions }, callback: MultiCallback): void;
observe(key: string, options: ObserveOptions, callback: KeyCallback): void;
observeMulti(kv: { [key: string]: ObserveMultiOptionsForValue }, options: { [key: string]: ObserveMultiOptions }, callback: MultiCallback): void;
on(event: string, listener: Function): void;
on(event: 'connect', listener: (err: Error) => any): void;
on(event: 'error', listener: (err: Error) => any): void;
prepend(key: string, fragment: string, callback: KeyCallback): void;
prepend(key: string, fragment: string, options: PrependOptions, callback: KeyCallback): void;
prepend(key: string, fragment: Buffer, callback: KeyCallback): void;
prepend(key: string, fragment: Buffer, options: PrependOptions, callback: KeyCallback): void;
prependMulti(kv: { [key: string]: PrependMultiOptionsFoValue }, options: { [key: string]: PrependMultiOptions }, callback: MultiCallback): void;
remove(key: string, callback: KeyCallback): void;
remove(key: string, options: RemoveOptions, callback: KeyCallback): void;
removeMulti(kv: { [key: string]: RemoveMultiOptionsForValue }, options: RemoveMultiOptions, callback: MultiCallback): void;
removeMulti(kv: string[], options: RemoveMultiOptions, callback: MultiCallback): void;
removeDesignDoc(name: string, callback: DDocCallback): void;
replace(key: string, value: any, callback: KeyCallback): void;
replace(key: string, value: any, options: ReplaceOptions, callback: KeyCallback): void;
replaceMulti(kv: { [key: string]: ReplaceMultiOptionsForValue }, options: ReplaceMultiOptions, callback: MultiCallback): void;
set(key: string, value: any, callback: KeyCallback): void;
set(key: string, value: any, options: SetOptions, callback: KeyCallback): void;
setMulti(kv: { [key: string]: SetMultiOptionsForValue }, options: SetMultiOptions, callback: MultiCallback): void;
setDesignDoc(name: string, data: any, callback: DDocCallback): void;
shutdown(): void;
stats(callback: StatsCallback): void;
stats(key: string, callback: StatsCallback): void;
strError(code: number): string;
touch(key: string, callback: KeyCallback): void;
touch(key: string, options: TouchOptions, callback: KeyCallback): void;
unlock(key: string, options: UnlockOptions, callback: KeyCallback): void;
unlockMulti(kv: { [key: string]: UnlockMultiOptionsForValue }, options: { [key: string]: UnlockMultiOptions }, callback: UnlockMultiOptions): void;
view(ddoc: string, name: string): ViewQuery;
view(ddoc: string, name: string, query: any): ViewQuery;
}
export class ViewQuery {
firstPage(q: any, callback: Function): void;
query(q: any, callback: Function): void;
}
}

View File

@@ -197,6 +197,17 @@ declare module 'couchbase' {
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.
*/
@@ -206,7 +217,7 @@ declare module 'couchbase' {
* @param name
* @param callback
*/
createBucket(name: string, callback: Function);
createBucket(name: string, callback: Function): void;
/**
*
@@ -214,20 +225,20 @@ declare module 'couchbase' {
* @param opts
* @param callback
*/
createBucket(name: string, opts: any, callback: Function);
createBucket(name: string, opts: any, callback: Function): void;
/**
*
* @param callback
*/
listBuckets(callback: Function);
listBuckets(callback: Function): void;
/**
*
* @param name
* @param callback
*/
removeBucket(name: string, callback: Function);
removeBucket(name: string, callback: Function): void;
}
/**
@@ -244,17 +255,17 @@ declare module 'couchbase' {
/**
* 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;
cas?: Bucket.CAS;
/**
* Ensures this operation is persisted to this many nodes.
*/
persist_to: number;
persist_to?: number;
/**
* Ensures this operation is replicated to this many nodes.
*/
replicate_to: number;
replicate_to?: number;
}
interface PrependOptions extends AppendOptions { }
@@ -265,7 +276,7 @@ declare module 'couchbase' {
/**
* Set the initial expiration time for the document. A value of 0 represents never expiring.
*/
expiry: number;
expiry?: number;
}
interface UpsertOptions extends ReplaceOptions { }
@@ -274,38 +285,38 @@ declare module 'couchbase' {
/**
* Ensures this operation is persisted to this many nodes.
*/
persist_to: number;
persist_to?: number;
/**
* Ensures this operation is replicated to this many nodes.
*/
replicate_to: number;
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;
initial?: number;
/**
* Set the initial expiration time for the document. A value of 0 represents never expiring.
*/
expiry: number;
expiry?: number;
/**
* Ensures this operation is persisted to this many nodes
*/
persist_to: number;
persist_to?: number;
/**
* Ensures this operation is replicated to this many nodes
*/
replicate_to: number;
replicate_to?: number;
}
interface GetAndLockOptions {
lockTime: number;
lockTime?: number;
}
interface GetReplicaOptions {
@@ -313,7 +324,7 @@ declare module 'couchbase' {
/**
* 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;
index?: number;
}
interface InsertOptions {
@@ -321,17 +332,17 @@ declare module 'couchbase' {
/**
* Set the initial expiration time for the document. A value of 0 represents never expiring.
*/
expiry: number;
expiry?: number;
/**
* Ensures this operation is persisted to this many nodes.
*/
persist_to: number;
persist_to?: number;
/**
* Ensures this operation is replicated to this many nodes.
*/
replicate_to: number;
replicate_to?: number;
}
/**
@@ -343,20 +354,20 @@ declare module 'couchbase' {
* 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);
flush(callback: Function): void;
/**
* Retrieves a specific design document from this bucket.
* @param name
* @param callback The callback function.
*/
getDesignDocument(name: string, 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);
getDesignDocuments(callback: Function): void;
/**
* Registers a design document to this bucket, failing if it already exists.
@@ -365,7 +376,7 @@ declare module 'couchbase' {
* @param callback The callback function.
* @returns {}
*/
insertDesignDocument(name: string, data: any, callback: Function);
insertDesignDocument(name: string, data: any, callback: Function): void;
/**
* Unregisters a design document from this bucket.
@@ -373,7 +384,7 @@ declare module 'couchbase' {
* @param callback The callback function.
* @returns {}
*/
removeDesignDocument(name: string, callback: Function);
removeDesignDocument(name: string, callback: Function): void;
/**
* Registers a design document to this bucket, overwriting any existing design document that was previously registered.
@@ -382,7 +393,7 @@ declare module 'couchbase' {
* @param callback The callback function.
* @returns {}
*/
upsertDesignDocument(name: string, data: any, callback: Function);
upsertDesignDocument(name: string, data: any, callback: Function): void;
}
/**
@@ -745,7 +756,7 @@ declare module 'couchbase' {
* @param fragment The document's contents to append.
* @param callback The callback function.
*/
append(key: any | Buffer, fragment: any, callback: Bucket.OpCallback);
append(key: any | Buffer, fragment: any, callback: Bucket.OpCallback): void;
/**
*
@@ -754,7 +765,7 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
append(key: any | Buffer, fragment: any, options: AppendOptions, callback: Bucket.OpCallback);
append(key: any | Buffer, fragment: any, options: AppendOptions, callback: Bucket.OpCallback): void;
/**
* Increments or decrements a key's numeric value.
@@ -763,7 +774,7 @@ declare module 'couchbase' {
* @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);
counter(key: any | Buffer, delta: number, callback: Bucket.OpCallback): void;
/**
*
@@ -772,7 +783,7 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
counter(key: any | Buffer, delta: number, options: CounterOptions, callback: Bucket.OpCallback);
counter(key: any | Buffer, delta: number, options: CounterOptions, callback: Bucket.OpCallback): void;
/**
* Shuts down this connection.
@@ -783,21 +794,21 @@ declare module 'couchbase' {
* 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[]);
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);
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);
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.
@@ -806,7 +817,7 @@ declare module 'couchbase' {
* @param key The target document key.
* @param callback The callback function.
*/
getAndLock(key: any, callback: Bucket.OpCallback);
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.
@@ -817,7 +828,7 @@ declare module 'couchbase' {
* @param callback The callback function.
* @returns {}
*/
getAndLock(key: any, options: GetAndLockOptions, callback: Bucket.OpCallback);
getAndLock(key: any, options: GetAndLockOptions, callback: Bucket.OpCallback): void;
/**
* Retrieves a document and updates the expiry of the item at the same time.
@@ -826,7 +837,7 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
getAndTouch(key: any | Buffer, expiry: number, options: any, callback: Bucket.OpCallback);
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.
@@ -834,21 +845,21 @@ declare module 'couchbase' {
* @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);
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);
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);
getReplica(key: any | Buffer, callback: Bucket.OpCallback): void;
/**
* Get a document from a replica server in your cluster.
@@ -856,7 +867,7 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
getReplica(key: any | Buffer, options: GetReplicaOptions, callback: Bucket.OpCallback);
getReplica(key: any | Buffer, options: GetReplicaOptions, callback: Bucket.OpCallback): void;
/**
* Identical to Bucket#upsert but will fail if the document already exists.
@@ -864,7 +875,7 @@ declare module 'couchbase' {
* @param value The document's contents.
* @param callback The callback function.
*/
insert(key: any | Buffer, value: any, callback: Bucket.OpCallback);
insert(key: any | Buffer, value: any, callback: Bucket.OpCallback): void;
/**
* Identical to Bucket#upsert but will fail if the document already exists.
@@ -873,7 +884,7 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
insert(key: any | Buffer, value: any, options: InsertOptions, callback: Bucket.OpCallback);
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.
@@ -886,7 +897,7 @@ declare module 'couchbase' {
* @param fragment The document's contents to prepend.
* @param callback The callback function.
*/
prepend(key: any, fragment: any, callback: Bucket.OpCallback);
prepend(key: any, fragment: any, callback: Bucket.OpCallback): void;
/**
* Like Bucket#append, but prepends data to the existing value.
@@ -895,7 +906,7 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
prepend(key: any, fragment: any, options: PrependOptions, callback: Bucket.OpCallback);
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.
@@ -919,7 +930,7 @@ declare module 'couchbase' {
* @param key The target document key.
* @param callback The callback function.
*/
remove(key: any | Buffer, callback: Bucket.OpCallback);
remove(key: any | Buffer, callback: Bucket.OpCallback): void;
/**
* Deletes a document on the server.
@@ -927,7 +938,7 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
remove(key: any | Buffer, options: RemoveOptions, callback: Bucket.OpCallback);
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).
@@ -935,7 +946,7 @@ declare module 'couchbase' {
* @param value The document's contents.
* @param callback The callback function.
*/
replace(key: any | Buffer, value: any, callback: Bucket.OpCallback);
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).
@@ -944,14 +955,14 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
replace(key: any | Buffer, value: any, options: ReplaceOptions, callback: Bucket.OpCallback);
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);
setTranscoder(encoder: Bucket.EncoderFunction, decoder: Bucket.DecoderFunction): void;
/**
* Update the document expiration time.
@@ -960,7 +971,7 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
touch(key: any | Buffer, expiry: number, options: TouchOptions, callback: Bucket.OpCallback);
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.
@@ -968,7 +979,7 @@ declare module 'couchbase' {
* @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);
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.
@@ -977,7 +988,7 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
unlock(key: any | Buffer, cas: Bucket.CAS, options: any, callback: Bucket.OpCallback);
unlock(key: any | Buffer, cas: Bucket.CAS, options: any, callback: Bucket.OpCallback): void;
/**
* Stores a document to the bucket.
@@ -985,7 +996,7 @@ declare module 'couchbase' {
* @param value The document's contents.
* @param callback The callback function.
*/
upsert(key: any | Buffer, value: any, callback: Bucket.OpCallback);
upsert(key: any | Buffer, value: any, callback: Bucket.OpCallback): void;
/**
* Stores a document to the bucket.
@@ -994,7 +1005,7 @@ declare module 'couchbase' {
* @param options The options object.
* @param callback The callback function.
*/
upsert(key: any | Buffer, value: any, options: UpsertOptions, callback: Bucket.OpCallback);
upsert(key: any | Buffer, value: any, options: UpsertOptions, callback: Bucket.OpCallback): void;
}
module Bucket {