Skip to content

Set Keys and Values

Description

This operation modifies values associated with one or more keys.  If the specified keys do not exist, new key-value pairs are created.

Method

Backendless.Hive( hiveName ).KeyValueStore.set( values ): Promise<void>;

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
values A JavaScript object with properties (keys) and the corresponding values to be used as key-value pairs by the operation.

Return Value

None.

Example

The example below modifies values associated with the keys 'Japan' and 'USA'. In case the specified keys do not exist, new key-value pairs are created.

await Backendless.Hive('countries').KeyValueStore.set({ 'Japan': 'The land of the rising sun', 'USA': 'The country of freedom' })

where:

Argument                Description
'countries' Name of a hive where the operation is performed.
'Japan','USA' Keys to update the values for. If a key does not exist, a new key-value pair is created.
'The land of the rising sun','The country of freedom' Values to assign to the 'Japan' and 'USA' keys.

Codeless Reference

keyvalue_api_set_keys_and_values

where:

Argument                Description
hive name Name of a hive where the operation is performed.
keys/values object An object containing key names and corresponding values.

Consider the following Key Value storage:

sample-key-value

The following example sets key-value pairs:

keyvalue_api_example_set_keys_and_values


The key-value storage will look as shown below after the Codeless logic runs:
keyvalue_api_example_set_keys_and_values_2