RiakObject Class
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
()
Item Index
Methods
- addToIndex
- getBucket
- getBucketType
- getContentEncoding
- getContentType
- getIndex
- getIndexes
- getIsTombstone
- getKey
- getLastModified
- getLinks deprecated
- getUserMeta
- getValue
- getVClock
- hasIndexes
- hasLinks deprecated
- hasUserMeta
- populateRpbContentFromRiakObject static
- setBucket
- setBucketType
- setContentEncoding
- setContentType
- setIndex
- setKey
- setLinks deprecated
- setUserMeta
- setValue
- setVClock
Methods
addToIndex
-
indexName
-
key
Add one or more keys to an index.
If the index does not exist it will be created.
Parameters:
-
indexName
Stringthe index name
-
key
String | Number multiple1 or more keys to add
getBucket
()
String
Get the bucket.
Returns:
the bucket.
getBucketType
()
String
Get the bucket type.
Returns:
the bucket type.
getContentEncoding
()
String
Get the content encoding
Returns:
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:
the content type.
getIndex
-
indexName
Get the keys for an index.
Parameters:
-
indexName
Stringthe name of the index
Returns:
the keys
getIndexes
()
Object
Get all indexes.
Returns:
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:
true if this is a tombstone.
getKey
()
String
Get the key.
Returns:
the key.
getLastModified
()
Number
Returns the last modified time of this RiakObject.
The timestamp is returned as a (Unix) epoch time.
Returns:
the last modified time.
getLinks
()
Object
deprecated
Get the links.
This is an array of objects representing links to other objects in Riak.
Note that link walking is a deprecated feature in Riak 2.0.
See: Link Walking
Returns:
An array containing the links, or undefined if none exist.
getUserMeta
()
Object
Get the user meta data
This is an array of key/value objects
Returns:
array of key/value objects
getValue
()
Buffer | Object
Get the value.
This will either be a Buffer or a plain JS object.
Returns:
The value returned from Riak.
getVClock
()
Buffer
Get the vector clock.
Returns:
The vector clock retrieved from Riak.
hasIndexes
()
Boolean
Determine if any indexes are present.
Returns:
true if indexes are present.
hasLinks
()
Boolean
deprecated
Determine if any links are present.
Note that link walking is a deprecated feature in Riak 2.0.
See: Link Walking
Returns:
true if there are any links.
hasUserMeta
()
Boolean
Determine if any user metadata is present.
Returns:
true if user meta data is present.
populateRpbContentFromRiakObject
-
ro
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:
-
ro
RiakObjectThe RiakObject
Returns:
a RpbContent protobuf
setBucket
-
bucket
Set the bucket.
Parameters:
-
bucket
Stringthe bucket in Riak.
setBucketType
-
bucketType
Set the bucket type.
If this is not set 'default' is used.
Parameters:
-
bucketType
Stringthe bucket type in Riak.
setContentEncoding
-
contentEncoding
Set the content encoding.
Parameters:
-
contentEncoding
Stringthe content encoding
setContentType
-
contentType
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
Stringthe content type.
setIndex
-
indexName
-
arrayOfKeys
Set an index, replacing the existing value if any.
Parameters:
-
indexName
Stringthe index name
-
arrayOfKeys
String | Number- the keys
setKey
-
key
Set the key.
Parameters:
-
key
Stringthe key in Riak.
setLinks
-
links
Set the links.
This is an array of objects representing links to other objects in Riak.
Note that link walking is a deprecated feature in Riak 2.0.
See: Link Walking
Parameters:
-
links
ObjectAn array of objects representing the links.
-
bucket
StringThe bucket the linked object is in.
-
key
StringThe key for the linked object.
-
tag
StringThe identifier that describes the relationship you are wishing to capture with your link
-
setUserMeta
-
userMeta
Set the user meta data.
This is an array of key/value objects.
Parameters:
-
userMeta
Object-
key
Stringusermeta key
-
value
Stringusermeat value
-
setValue
-
value
Set the value.
Parameters:
-
value
String | Buffer | Objectthe value stored in Riak.
setVClock
-
vclock
Set the vector clock.
Parameters:
-
vclock
Bufferthe vclock retrieved from Riak