Skip to content

Add Values

Description

This operation adds new elements to a set. Duplicate values are ignored.

Method

// Add a Single Value
Backendless.Hive(hiveName).SetStore(keyName).add(value);

// Add Multiple Values
Backendless.Hive(hiveName).SetStore(keyName).add(values);

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a set. String value.
value A value to add to the set. The value can be of any data type.
values A set of values to add to the set. Values can be of any data type.

Return Value

Number of elements added to the set.

Example

Add a Single Value

The example below adds a new value "SUV" to the "cars" set.

Backendless.Hive("transport").SetStore("cars").add("SUV");

where:

Argument                Description
"transport" Name of a hive where the operation is performed.
"cars" Key name identifying a set.

Add Multiple Values

The example below adds new values "SUV"  and "Coupe" to the "cars" set.

Set<Object> values = new HashSet<>();
keyNames.add( "SUV" );
keyNames.add( "Coupe" );

Backendless.Hive("transport").SetStore("cars").add(values);

where:

Argument                Description
"transport" Name of a hive where the operation is performed.
"cars" Key name identifying a set.

Codeless Reference

set_api_add_items

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a set.
items A list of items to add to the set.

Returns the number of elements added to the set.

Consider the following Set storage:
set_api_example_all_blocks

The example below adds "SUV" and "Coupe" to the "cars" set:
set_api_example_add_items

The set will look as shown below after the Codeless logic runs:
set_api_example_special_blocks_1