Class Connection

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

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

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!'); } });

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(callback: ConnectCallback): Connection

Parameters

Returns

Connection

constructor(options: ConnectionOptions, callback: ConnectCallback): Connection

Parameters

Returns

Connection

Properties

public clientVersion: Array<any>

Get information about the Couchnode version (i.e. this library) as an array of [versionNumber, versionString].

member

{Mixed[]} Connection#clientVersion

public connectionTimeout: number

public lcbVersion: Array<any>

public operationTimeout: number

public serverNodes: Array<string>

Methods

public add(key: string, value: any, callback: KeyCallback)

Parameters

public add(key: string, value: any, options: AddOptions, callback: KeyCallback)

Parameters

public addMulti(kv: { [key: string]: 'couchbase'.AddMultiOptionsForValue; }, options: AddMultiOptions, callback: MultiCallback)

Parameters

public append(key: string, fragment: string, callback: KeyCallback)

Parameters

public append(key: string, fragment: string, options: AppendOptions, callback: KeyCallback)

Parameters

public append(key: string, fragment: Buffer, callback: KeyCallback)

Parameters

public append(key: string, fragment: Buffer, options: AppendOptions, callback: KeyCallback)

Parameters

public appendMulti(kv: { [key: string]: 'couchbase'.AppendMultiOptionsForValue; }, options: AppendMultiOptions, callback: MultiCallback)

Parameters

public decr(key: string, callback: KeyCallback)

Parameters

public decr(key: string, options: DecrOptions, callback: KeyCallback)

Parameters

public decrMulti(kv: { [key: string]: 'couchbase'.DecrMultiOptionsForValue; }, options: DecrMultiOptions, callback: MultiCallback)

Parameters

public get(key: string, callback: KeyCallback)

Parameters

public get(key: string, options: GetOptions, callback: KeyCallback)

Parameters

public getDesignDoc(name: string, callback: DDocCallback)

Parameters

public getMulti(kv: Array<string>, options: { [key: string]: 'couchbase'.GetMultiOptions; }, callback: MultiCallback)

Parameters

  • kv: Array<string>
  • options: { [key: string]: 'couchbase'.GetMultiOptions; }
  • callback: MultiCallback

public getReplica(key: string, callback: KeyCallback)

Parameters

public getReplica(key: string, options: GetReplicaOptions, callback: KeyCallback)

Parameters

public getReplicaMulti(kv: Array<string>, options: GetReplicaMultiOptions, callback: MultiCallback)

Parameters

public incr(key: string, callback: KeyCallback)

Parameters

public incr(key: string, options: IncrOptions, callback: KeyCallback)

Parameters

public incrMulti(kv: { [key: string]: 'couchbase'.IncrMultiOptionsForValue; }, options: IncrMultiOptions, callback: MultiCallback)

Parameters

public lock(key: string, callback: KeyCallback)

Parameters

public lock(key: string, options: LockOptions, callback: KeyCallback)

Parameters

public lockMulti(kv: Array<string>, options: { [key: string]: 'couchbase'.LockMultiOptions; }, callback: MultiCallback)

Parameters

  • kv: Array<string>
  • options: { [key: string]: 'couchbase'.LockMultiOptions; }
  • callback: MultiCallback

public observe(key: string, options: ObserveOptions, callback: KeyCallback)

Parameters

public observeMulti(kv: { [key: string]: 'couchbase'.ObserveMultiOptionsForValue; }, options: { [key: string]: 'couchbase'.ObserveMultiOptions; }, callback: MultiCallback)

Parameters

  • kv: { [key: string]: 'couchbase'.ObserveMultiOptionsForValue; }
  • options: { [key: string]: 'couchbase'.ObserveMultiOptions; }
  • callback: MultiCallback

public on(event: string, listener: Function)

Parameters

  • event: string
  • listener: Function

public on(event: "'connect'", listener: (err: Error) => any)

Parameters

  • event: "'connect'"
  • listener: (err: Error) => any

public on(event: "'error'", listener: (err: Error) => any)

Parameters

  • event: "'error'"
  • listener: (err: Error) => any

public prepend(key: string, fragment: string, callback: KeyCallback)

Parameters

public prepend(key: string, fragment: string, options: PrependOptions, callback: KeyCallback)

Parameters

public prepend(key: string, fragment: Buffer, callback: KeyCallback)

Parameters

public prepend(key: string, fragment: Buffer, options: PrependOptions, callback: KeyCallback)

Parameters

public prependMulti(kv: { [key: string]: 'couchbase'.PrependMultiOptionsFoValue; }, options: { [key: string]: 'couchbase'.PrependMultiOptions; }, callback: MultiCallback)

Parameters

  • kv: { [key: string]: 'couchbase'.PrependMultiOptionsFoValue; }
  • options: { [key: string]: 'couchbase'.PrependMultiOptions; }
  • callback: MultiCallback

public remove(key: string, callback: KeyCallback)

Parameters

public remove(key: string, options: RemoveOptions, callback: KeyCallback)

Parameters

public removeDesignDoc(name: string, callback: DDocCallback)

Parameters

public removeMulti(kv: { [key: string]: 'couchbase'.RemoveMultiOptionsForValue; }, options: RemoveMultiOptions, callback: MultiCallback)

Parameters

public removeMulti(kv: Array<string>, options: RemoveMultiOptions, callback: MultiCallback)

Parameters

public replace(key: string, value: any, callback: KeyCallback)

Parameters

public replace(key: string, value: any, options: ReplaceOptions, callback: KeyCallback)

Parameters

public replaceMulti(kv: { [key: string]: 'couchbase'.ReplaceMultiOptionsForValue; }, options: ReplaceMultiOptions, callback: MultiCallback)

Parameters

public set(key: string, value: any, callback: KeyCallback)

Parameters

public set(key: string, value: any, options: SetOptions, callback: KeyCallback)

Parameters

public setDesignDoc(name: string, data: any, callback: DDocCallback)

Parameters

public setMulti(kv: { [key: string]: 'couchbase'.SetMultiOptionsForValue; }, options: SetMultiOptions, callback: MultiCallback)

Parameters

public shutdown()

public stats(callback: StatsCallback)

Parameters

public stats(key: string, callback: StatsCallback)

Parameters

public strError(code: number): string

Parameters

  • code: number

Returns

string

public touch(key: string, callback: KeyCallback)

Parameters

public touch(key: string, options: TouchOptions, callback: KeyCallback)

Parameters

public unlock(key: string, options: UnlockOptions, callback: KeyCallback)

Parameters

public unlockMulti(kv: { [key: string]: 'couchbase'.UnlockMultiOptionsForValue; }, options: { [key: string]: 'couchbase'.UnlockMultiOptions; }, callback: UnlockMultiOptions)

Parameters

  • kv: { [key: string]: 'couchbase'.UnlockMultiOptionsForValue; }
  • options: { [key: string]: 'couchbase'.UnlockMultiOptions; }
  • callback: UnlockMultiOptions

public view(ddoc: string, name: string): ViewQuery

Parameters

  • ddoc: string
  • name: string

Returns

ViewQuery

public view(ddoc: string, name: string, query: any): ViewQuery

Parameters

  • ddoc: string
  • name: string
  • query: any

Returns

ViewQuery