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
()
Item Index
Methods
withBucket
-
bucket
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
Stringthe bucket in Riak
withBucketType
-
bucketType
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
Stringthe bucket type in riak
withCallback
-
callback
Set the callback to be executed when the operation completes.
Parameters:
-
callback
FunctionThe allback to be executed when the operation completes.
-
err
StringAn error message. Will be null if no error.
-
response
ObjectThe response from Riak
-
vclock
BufferThe 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
StringThe key generated by Riak if one was not supplied.
-
-
withContent
-
value
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 | Objectthe data to store in Riak
withDw
-
dw
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
Numberthe DW value.
withIfNoneMatch
-
ifNoneMatch
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
Booleanthe if_non-match value.
withIfNotModified
-
ifNotModified
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
Booleanthe if_not_modified value.
withKey
-
key
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
Stringthe key in riak.
withPw
-
pw
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
Numberthe PW value.
withReturnBody
-
returnBody
-
[convertToJs]
-
[conflictResolver]
Return the object after storing (including any siblings). If siblings are present, an optional conflictResolver can be provided to resolve them.
Parameters:
-
returnBody
Booleantrue to return the object.
-
[convertToJs]
Boolean optionalconvert the returned value(s) to JS objects using JSON.parse()
-
[conflictResolver]
Function optionalthe conflict resolver
-
riakobjects
RiakObject[]array of RiakObjects returned by Riak.
-
withReturnHead
-
[conflictResolver]
-
returnHead
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 optionalthe conflict resolver
-
riakobjects
RiakObject[]array of RiakObjects returned by Riak.
-
-
returnHead
Booleantrue to return only metadata.
withTimeout
-
timeout
Set a timeout for this operation.
Parameters:
-
timeout
Numbera 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
Buffera vector clock returned from a previous fetch
withW
-
w
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
Numberthe W value.