API Docs for: 2.2.2
Show:

UpdateCounter.Builder Class

A builder for constructing UpdateCounter instances.

Rather than having to manually construct the options and instantiating a UpdateCounter directly, this builder may be used.

var update = new UpdateCounter.Builder()
          .withBucketType('counters')
          .withBucket('myBucket')
          .withKey('counter_1')
          .withIncrement(100)
          .withCallback(callback)
          .build();

Constructor

UpdateCounter.Builder

()

Methods

build

() UpdateCounter

Construct a UpdateCounter instance.

Returns:

UpdateCounter:

a UpdateCounter instance

withBucket

(
  • bucket
)
chainable

Set the bucket.

Parameters:

  • bucket String

    the bucket in Riak

withBucketType

(
  • bucketType
)
chainable

Set the bucket type.

Parameters:

  • bucketType String

    the bucket type in riak

withCallback

(
  • callback
)
chainable

Set the callback to be executed when the operation completes.

Parameters:

  • 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 ne null if returnBody not set.

      • generatedKey String
        If no key was supplied, Riak will generate and return one here.
      • counterValue Number
        The value of the counter in Riak.

withDw

(
  • dw
)
chainable

Set the DW value. How many replicas to commit to durable storage before returning a successful response. If not set the bucket default is used.

Parameters:

  • dw Number

    the DW value.

withIncrement

(
  • increment
)
chainable

Set the increment to apply to this counter. This may be negative as well as positive.

Parameters:

  • increment Number

    the amount to increment (negative to decrement)

withKey

(
  • key
)
chainable

Set the key. If not set Riak will generate one.

Parameters:

  • key String

    the key in riak.

withPw

(
  • pw
)
chainable

Set the PW value. How many primary nodes must be up when the write is attempted. If not set the bucket default is used.

Parameters:

  • pw Number

    the PW value.

withReturnBody

(
  • returnBody
)
chainable

Return the counter after updating.

Parameters:

  • returnBody Boolean

    true to return the counter.

withTimeout

(
  • timeout
)
chainable

Set a timeout for this operation.

Parameters:

  • timeout Number

    a timeout in milliseconds.

withW

(
  • w
)
chainable

Set the W value. How many replicas to write to before returning a successful response. If not set the bucket default is used.

Parameters:

  • w Number

    the W value.