API Docs for: 2.2.2
Show:

StoreValue.Builder Class

A builder for constructing StoreValue instances.

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

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

Constructor

StoreValue.Builder

()

Methods

build

() StoreValue

Construct a StoreValue instance.

Returns:

StoreValue:

a StoreValue instance

withBucket

(
  • bucket
)
chainable

Set the bucket. Note that this can also be provided via RiakObject passed in via withContent() and doing so will take precidence over this method.

Parameters:

  • bucket String

    the bucket in Riak

withBucketType

(
  • bucketType
)
chainable

Set the bucket type. If not supplied, 'default' is used. Note that this can also be provided via RiakObject passed in via withContent() and doing so will take precidence over this method.

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 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.

withContent

(
  • value
)
chainable

Set the value and its metadata to be stored in Riak. If a JS object is supplied, it will be converted to JSON using JSON.stringify()

Parameters:

  • value RiakObject | String | Buffer | Object

    the data to store 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.

withIfNoneMatch

(
  • ifNoneMatch
)
chainable

Set the if_none_match flag.

Setting this to true means store the value only if this bucket/key combination are not already defined.

Be aware that there are several cases where this may not actually happen. Use of this option is discouraged.

Parameters:

  • ifNoneMatch Boolean

    the if_non-match value.

withIfNotModified

(
  • ifNotModified
)
chainable

Set the if_not_modified flag.

Setting this to true means to store the value only if the supplied vclock matches the one in the database.

Be aware there are several cases where this may not actually happen. Use of this feature is discouraged.

Parameters:

  • ifNotModified Boolean

    the if_not_modified value.

withKey

(
  • key
)
chainable

Set the key. If not set, riak will generate and return a key. Note that this can also be provided via RiakObject passed in via withContent() and doing so will take precidence over this method.

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
  • [convertToJs]
  • [conflictResolver]
)
chainable

Return the object after storing (including any siblings). If siblings are present, an optional conflictResolver can be provided to resolve them.

Parameters:

  • returnBody Boolean

    true to return the object.

  • [convertToJs] Boolean optional

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

  • [conflictResolver] Function optional

    the conflict resolver

    • riakobjects RiakObject[]

      array of RiakObjects returned by Riak.

withReturnHead

(
  • [conflictResolver]
  • returnHead
)
chainable

Return the metadata after storing the value.

Causes Riak to only return the metadata for the object. If siblings are present, an optional conflictResolver can be provided to resolve them.

Parameters:

  • [conflictResolver] Function optional

    the conflict resolver

    • riakobjects RiakObject[]

      array of RiakObjects returned by Riak.

  • returnHead Boolean

    true to return only metadata.

withTimeout

(
  • timeout
)
chainable

Set a timeout for this operation.

Parameters:

  • timeout Number

    a timeout in milliseconds.

withVClock

(
  • vclock
)

Set the vector clock. Convenience method if a RiakObject is not supplied as content. Note that a vclock supplied via RiakObject in withContent() will have precendence over this.

Parameters:

  • vclock Buffer

    a vector clock returned from a previous fetch

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.