API Docs for: 2.2.2
Show:

StoreValue Class

Extends CommandBase
Module: KV

Command used to store data in Riak.

As a convenience, a builder class is provided:

 var storeValue = new StoreValue.Builder()
     .withBucket('myBucket')
     .withKey('myKey')
     .withContent(myObj)
     .build();

See StoreValue.Builder

Constructor

StoreValue

(
  • options
  • callback
)

Parameters:

  • options Object

    The options for this command.

    • [bucketType=default] String optional

      The bucket type in riak. If not supplied 'default' is used.

    • bucket String

      The bucket in riak.

    • [key] String optional

      The key for the object you want to store.

    • [vclock] Buffer optional

      The vector clock to use.

    • value RiakObject | String | Buffer | Object

      The value to store in Riak. JS Objects will be passed to JSON.stringify().

    • [w] Number optional

      The W value to use.

    • [dw] Number optional

      The DW value to use.

    • [pw] Number optional

      The PW value to use.

    • [returnBody] Boolean optional

      Return the stored object and meta (incl. siblings)

    • [returnHead] Boolean optional

      Return the metatdata only for the stored object.

    • [convertToJs] Boolean optional

      Convert the returned value(s) to JS objects using JSON.parse()

    • [conflictResolver] Function optional

      A function used to resolve siblings to a single object.

      • objects RiakObject[] | Object
        The array of objects returned from Riak.
    • [timeout] Number optional

      Set a timeout for this command.

    • [ifNotModified] Boolean optional

      The if_not_modified flag.

    • [ifNoneMatch] Boolean optional

      The if_none_match flag.

  • callback Function

    The allback to be executed when the operation completes.

    • err String

      An error message. Will be null if no error.

    • response Object

      The response from Riak

      • vclock Buffer
        The vector clock for this object (and its siblings)
      • values Object | RiakObject[]
        An array of one or more values. Either RiakObjects or JS objects if convertToJs was used.
      • generatedKey String
        The key generated by Riak if one was not supplied.
    • data Object

      additional error data. Will be null if no error.

Methods

constructPbRequest

() Object protected
Construct and return the Riak protocol buffer message for this command. Subclasses must override this method.

Returns:

Object: a protocol buffer message builder

getCallback

() Function private
Fires the user's callback with the arguments passed in.

Returns:

Function: the user supplied callback

getExpectedResponseCode

() Number private
Returns the expected response code for this command.

Returns:

Number: the expected response code for this command.

getPbReqBuilder

() Object private
Returns and instance of the protocol buffer message builder for this command. This is determined via the pbRequestName passed to the constructor.

Returns:

Object: the builder for the protocol buffer message to be sent for this command

getRiakMessage

() Object private
Returns the encoded protobuf and message header.

Returns:

Object: object containing the header and encoded protobuf

onError

(
  • msg
  • data
)
protected
Called by RiakNode if an error occurs executing the command and all retries are exhausted.

Parameters:

  • msg String
    an error message
  • data Object
    additional error data

onRiakError

(
  • rpbErrorResp
)
protected
Called by RiakNode when a RpbErrorResp is received and all retries are exhausted. Commands may override this method.

Parameters:

  • rpbErrorResp Object
    the RpbErrorResp protocol buffer

onSuccess

(
  • pbResponseMessage
)
Boolean protected
Called by RiakNode when a response is received. Subclasses must override this method.

Parameters:

  • pbResponseMessage Object
    the protocol buffer received from riak

Returns:

Boolean: true if not streaming or the last response has been received, false otherwise.