Skip to content

Add First

Description

This operation adds new values to the very beginning of a list.

Method

Add One Value

Backendless.Hive(hiveName).ListStore(keyName).addFirst(value);

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a list. String value.
value Value to add to the list. Can be of any data type.

Add Multiple Values

Backendless.Hive(hiveName).ListStore(keyName).addFirst(values);

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a list. String value.
values An array of values to add to the list. Individual values can be of any data type.

Return Value

The number of values in the list after the new values are saved.

Example

Add One Value

The example below adds the new value "Apple" to the very beginning of the "fruits" list.

Backendless.Hive("groceryStore").ListStore("fruits").addFirst("Apple");

where:

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

Add Multiple Values

The example below adds the "Apple" and "Orange" values to the very beginning of the fruits list.

List<Object> values = new ArrayList<>();
values.add("Apple");
values.add("Orange");

Backendless.Hive("groceryStore").ListStore("fruits").addFirst(values);

where:

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

Codeless Reference

list_api_add_first

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a list.
items A list of values to add to the list.
position: first Instructs Hive to add the specified items at the beginning of the list.

Returns the number of values in the list after the new values are saved.

Consider the following List storage:

list_api_example_add_first_2

The example below adds "Apple" and "Orange" to the beginning of the list:
list_api_example_add_first

After the codeless logic runs, the list in Hive contains the following data:

list_api_example_get_values_2