API Docs for: 2.2.2
Show:

UpdateMap Class

Extends CommandBase
Module: CRDT

Command used to update a Map in Riak.

As a convenience, a builder method is provided as well as an object with a fluent API for constructing the update.

var mapOp = new UpdateMap.MapOperation();
mapOp.incrementCounter('counter_1', 50)
    .addToSet('set_1', 'set_value_1')
    .setRegister('register_1', new Buffer('register_value_1'))
    .setFlag('flag_1', true)
    .map('inner_map')
        .incrementCounter('counter_1', 50)
        .addToSet('set_2', 'set_value_2');

See UpdateMap.MapOperation

var update = new UpdateMap.Builder()
          .withBucketType('maps')
          .withBucket('myBucket')
          .withKey('map_1')
          .withMapOperation(mapOp)
          .withCallback(myCallback)
          .withReturnBody(true)
          .build();

See UpdateMap.Builder

Constructor

UpdateMap

(
  • options
  • callback
)

Parameters:

  • options Object

    The options to use for this command.

    • bucketType String

      The bucket type in riak.

    • bucket String

      The bucket in riak.

    • op MapOperation

      The set of modifications to make to this map.

    • [key] String optional

      The key for the counter you want to store. If not supplied Riak will gererate one.

    • [context] Buffer optional

      The context from a previous fetch. Required for remove operations.

    • [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=true] Boolean optional

      Return the map.

    • [setsAsBuffers=false] Boolean optional

      Return sets as arrays of Buffers rather than strings.

    • [timeout] Number optional

      Set a timeout for this command.

  • callback Function

    The callback to be executed when the operation completes.

    • err String

      An error message. Will be null if no error.

    • response Object

      The response from Riak. Will be null if returnBody is not set.

      • generatedKey String
        If no key was supplied, Riak will generate and return one here.
      • context Buffer
        An opaque context to be used in any subsequent modification of the map.
      • map Object
        The map in Riak, converted to a JS object.
    • 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.