Skip to content

Set Value By Key Name

Description

This operation replaces the value linked to a key in the map.

Method

Backendless.Hive(hiveName).MapStore(keyName).set(objKey, value);

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a map. String value.
objKey Name of the key whose value is replaced. String value.
value New value for the key. Can be of any data type.

Return Value

If the specified key does not exist, then this operation adds a new key-value pair to the map and returns true. Otherwise, returns false if a value associated with the specified key is replaced by a new value.

Example

The example below sets a new value 1.29 for the "Oranges" key. This invocation returns false indicating that the current value has been replaced.

Backendless.Hive("groceryStore").MapStore("fruits").set("Oranges", 1.29);

where:

Argument                Description
"groceryStore" Name of a hive where the operation is performed.
"fruits" Key name identifying a map.

Codeless Reference
map_api_set_values

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a map.
values(object) An object containing a new value for a key.

Returns false if an existing key-value pair is updated. Returns true if a new key-value pair is added to the map.

Consider the following Map storage:
map_apI_example_map_store

The example below sets a new value 1.29 for the "Oranges" key. If the specified key does not exist, then a new key-value pair is added to the map.

map_api_example_set_value_one
The map will look as shown below after the Codeless logic runs:
map_apI_example_map_store_5