StorageAdapter

StorageAdapter.errorCodes
static

mirrors native couchbase sdk require('couchbase').errors

Type:
Object
errorCodes

mirrors native couchbase sdk require('couchbase').errors

Type:
Object
StorageAdapter.errors
static
new StorageAdapter(options)

StorageAdapter

Parameters:
  • options optional
    • Type: Object
      • bucket optional
        • Type: Bucket
Throws:
append(key, value, options)Promise<Object>
Parameters:
  • key
  • value
    • Type: mixed
  • options optional
    • Type: Object
      • cas optional
        • Type: BucketCAS
        • optional 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.

      • expiry optional
        • Type: integer
        • Default: 0
        • Set the initial expiration time for the document. A value of 0 represents never expiring. If the value is greater than number of seconds in one month, the value must be provided in unix timestamp format.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<Object>
bulkInsert(documents, options)Promise<[PromiseInspection>, ...]

aync version

Parameters:
  • options optional
    • Type: Object
      • expiry optional
        • Type: integer
        • Default: 0
        • Set the initial expiration time for the document. A value of 0 represents never expiring. If the value is greater than number of seconds in one month, the value must be provided in unix timestamp format.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<[PromiseInspection>, ...]
bulkInsertSync(documents, options)Promise<Array>
Parameters:
  • options optional
    • Type: Object
      • expiry optional
        • Type: integer
        • Default: 0
        • Set the initial expiration time for the document. A value of 0 represents never expiring. If the value is greater than number of seconds in one month, the value must be provided in unix timestamp format.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<Array>
bulkRemove(entities, options)Promise<[PromiseInspection>, ...]

async version retruns always fullfiled promise with response implementing PromiseInspection

Parameters:
  • options optional
    • Type: Object
      • cas optional
        • Type: BucketCAS
        • optional 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.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<[PromiseInspection>, ...]
bulkRemoveSync(entities, options)Promise<Array>
Parameters:
  • options optional
    • Type: Object
      • cas optional
        • Type: BucketCAS
        • optional 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.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Throws:
Returns: Promise<Array>
counter(key, value, options)Promise<Object>

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).

Parameters:
  • key
    • Type: [(string | Buffer), ...]
  • value
    • Type: integer
  • options optional
    • Type: Object
      • initial optional
        • Type: integer
        • optional 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.

      • expiry optional
        • Type: integer
        • Default: 0
        • Set the initial expiration time for the document. A value of 0 represents never expiring. If the value is greater than number of seconds in one month, the value must be provided in unix timestamp format.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<Object>
disconnect()
enableN1ql(hosts)
Parameters:
  • hosts
    • Type: string or [string, ...]
exists(key)boolean

fake exists method which will perform insert operation. If the operation succeeds, the inserted document is removed and true is returned, otherwise false is returned

Note: In the future it could be replaced by LookupInBuilder.exists method (currently unstable) Currently, the most reliable option is to perform get operation (downside is that it is needless "wasting" of bandwidth, especially for larger documents)

Parameters:
  • key
    • Type: string or Key
Returns: boolean
get(key, options)Promise<Object>
Parameters:
  • key
  • options optional
    • Type: Object
      • paranoid optional
        • Type: boolean
        • default=true if false, both deleted and non-deleted documents will be returned. if true, it'll throw StorageError (not found) for a document which was sof-deleted.

      • deletedAtPropName optional
        • Type: string
        • should be provided if options.paranoid === false

Returns: Promise<Object>
getAndLock(key, options)Promise<Object>
Parameters:
  • key
  • options optional
    • Type: Object
      • lockTime optional
        • Type: integer
        • time in seconds, default=15, max=30

Returns: Promise<Object>
getAndTouch(key, expiry, options)Promise<Object>
Parameters:
  • key
  • expiry
    • Type: integer
    • time in seconds. If the value is greater than number of seconds in one month, the value must be provided in unix timestamp format.

  • options
    • Type: Object
Returns: Promise<Object>
getManager()BucketManager

Returns an instance of a BucketManager for performing management operations against a bucket.

Returns: BucketManager
getReplica(key, options)Promise<Object>
Parameters:
  • key
  • options optional
    • Type: Object
      • index optional
        • Type: intger
        • optional The index for which replica you wish to retrieve this value from, or if undefined, use the value from the first server that replies.

Returns: Promise<Object>
insert(key, data, options)Promise<Object>
Parameters:
  • key
  • data
    • Type: mixed
  • options optional
    • Type: Object
      • expiry optional
        • Type: integer
        • Default: 0
        • Set the initial expiration time for the document. A value of 0 represents never expiring. If the value is greater than number of seconds in one month, the value must be provided in unix timestamp format.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<Object>
prepend(key, value, options)Promise<Object>
Parameters:
  • key
  • value
    • Type: mixed
  • options optional
    • Type: Object
      • cas optional
        • Type: BucketCAS
        • optional 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.

      • expiry optional
        • Type: integer
        • Default: 0
        • Set the initial expiration time for the document. A value of 0 represents never expiring. If the value is greater than number of seconds in one month, the value must be provided in unix timestamp format.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<Object>
query(query, params)Promise<(Bucket.ViewQueryResponse | Bucket.N1qlQueryResponse)>

Executes a previously prepared query object. This could be a ViewQuery or a N1qlQuery.

Parameters:
  • query
    • Type: ViewQuery or N1qlQuery
    • The query to execute

  • params
    • Type: Object or Array
    • optional A list or map to do replacements on a N1QL query.

Returns: Promise<(Bucket.ViewQueryResponse | Bucket.N1qlQueryResponse)>
remove(key, options)Promise<Object>
Parameters:
  • key
  • options optional
    • Type: Object
      • cas optional
        • Type: BucketCAS
        • optional 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.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<Object>
replace(key, value, options)Promise<Object>

Identical to Bucket#set, but will only succeed if the document exists already.

Parameters:
  • key
  • value
    • Type: mixed
  • options optional
    • Type: Object
      • cas optional
        • Type: BucketCAS
        • optional 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.

      • expiry optional
        • Type: integer
        • Default: 0
        • Set the initial expiration time for the document. A value of 0 represents never expiring. If the value is greater than number of seconds in one month, the value must be provided in unix timestamp format.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<Object>
touch(key, expiry, options)Promise<Object>
Parameters:
  • key
  • expiry
    • Type: integer
    • In seconds. 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. If the value is greater than number of seconds in one month, the value must be provided in unix timestamp format.

  • options optional
    • Type: Object
      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<Object>
unlock(key, cas, options)Promise<Object>
Parameters:
  • key
  • cas
    • Type: Bucket.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.

  • options
    • Type: Object
Returns: Promise<Object>
upsert(key, value, options)Promise<Object>

Identical to Bucket#set, but will only succeed if the document exists already.

Parameters:
  • key
  • value
    • Type: mixed
  • options optional
    • Type: Object
      • cas optional
        • Type: BucketCAS
        • optional 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.

      • expiry optional
        • Type: integer
        • Default: 0
        • Set the initial expiration time for the document. A value of 0 represents never expiring. If the value is greater than number of seconds in one month, the value must be provided in unix timestamp format.

      • persist_to optional
        • Type: integer
        • optional default=0 Ensures this operation is persisted to this many nodes

      • replicate_to optional
        • Type: integer
        • optional default=0 Ensures this operation is replicated to this many nodes

Returns: Promise<Object>
comments powered by Disqus