API Docs for: 2.2.2
Show:

RiakObject Class

Module: KV

A class that encapsulates the metadata and value stored in Riak.

While you can fetch and store regular JS objects with FetchValue and StoreValue, if you want access to the associated metadata stored in Riak with the value you'll want to use a RiakObject instead.

Constructor

RiakObject

()

Methods

addToIndex

(
  • indexName
  • key
)
chainable

Add one or more keys to an index.

If the index does not exist it will be created.

Parameters:

  • indexName String

    the index name

  • key String | Number multiple

    1 or more keys to add

getBucket

() String

Get the bucket.

Returns:

String:

the bucket.

getBucketType

() String

Get the bucket type.

Returns:

String:

the bucket type.

getContentEncoding

() String

Get the content encoding

Returns:

String:

the content encoding

getContentType

() String

Get the content type.

Due to Riak's HTTP API this is represented as a string suitable for a HTTP Content-Type header.

Returns:

String:

the content type.

getIndex

(
  • indexName
)
String

Get the keys for an index.

Parameters:

  • indexName String

    the name of the index

Returns:

String:

the keys

getIndexes

() Object

Get all indexes.

Returns:

Object:

an object whose fields are the index names holding arrays of keys

getIsTombstone

() Boolean

Returns whether or not this RiakObject is marked as being deleted (a tombstone)

Returns:

Boolean:

true if this is a tombstone.

getKey

() String

Get the key.

Returns:

String:

the key.

getLastModified

() Number

Returns the last modified time of this RiakObject.

The timestamp is returned as a (Unix) epoch time.

Returns:

Number:

the last modified time.

getUserMeta

() Object

Get the user meta data

This is an array of key/value objects

Returns:

Object:

array of key/value objects

getValue

() Buffer | Object

Get the value.

This will either be a Buffer or a plain JS object.

Returns:

Buffer | Object:

The value returned from Riak.

getVClock

() Buffer

Get the vector clock.

Returns:

Buffer:

The vector clock retrieved from Riak.

hasIndexes

() Boolean

Determine if any indexes are present.

Returns:

Boolean:

true if indexes are present.

hasUserMeta

() Boolean

Determine if any user metadata is present.

Returns:

Boolean:

true if user meta data is present.

populateRpbContentFromRiakObject

(
  • ro
)
Object private static

Creates and returns a RpbContent protobuf from a value and meta.

If the value is a JS Object it is converted using JSON.stringify().

Parameters:

Returns:

Object:

a RpbContent protobuf

setBucket

(
  • bucket
)
chainable

Set the bucket.

Parameters:

  • bucket String

    the bucket in Riak.

setBucketType

(
  • bucketType
)
chainable

Set the bucket type.

If this is not set 'default' is used.

Parameters:

  • bucketType String

    the bucket type in Riak.

setContentEncoding

(
  • contentEncoding
)
chainable

Set the content encoding.

Parameters:

  • contentEncoding String

    the content encoding

setContentType

(
  • contentType
)
chainable

Set the content type.

Due to Riak's HTTP API this is represented as a string suitable for a HTTP Content-Type header.

If not set, the default is 'application/json'

Parameters:

  • contentType String

    the content type.

setIndex

(
  • indexName
  • arrayOfKeys
)
chainable

Set an index, replacing the existing value if any.

Parameters:

  • indexName String

    the index name

  • arrayOfKeys String | Number
    • the keys

setKey

(
  • key
)
chainable

Set the key.

Parameters:

  • key String

    the key in Riak.

setUserMeta

(
  • userMeta
)
chainable

Set the user meta data.

This is an array of key/value objects.

Parameters:

  • userMeta Object
    • key String

      usermeta key

    • value String

      usermeat value

setValue

(
  • value
)
chainable

Set the value.

Parameters:

  • value String | Buffer | Object

    the value stored in Riak.

setVClock

(
  • vclock
)
chainable

Set the vector clock.

Parameters:

  • vclock Buffer

    the vclock retrieved from Riak