Skip to content

Get Key Items

Description

This operation returns the values for the specified keys. It has variations where it can return a single value for a key or a range of values based on indexes.

Method

Get All Values

Backendless.Hive(hiveName).ListStore(keyName).get();

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a list. String value.

Get Value By Index

Every element in a list is located at a specific index position. The operation accepts an index to return the value located in that position. List indexes are zero-based, it means the very first element in a List has the index of 0. However, you can also use a negative index, for instance -1 to return the last item from that list, -2 points to the second to last and so on. For more information about the indexes see the Hive Overview section of this guide.

Backendless.Hive(hiveName).ListStore(keyName).get(index);

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a list. String value.
index An index position of a specific value in the list.

Get Range Of Values

This format of the operation retrieves a range of values by using two index positions to form a range.

Backendless.Hive(hiveName).ListStore(keyName).get(start, stop);

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a list. String value.
start The start argument identifies the first value to get by index position.
stop The stop argument identifies the last value to get by index position.

Return Value

One value when this operation uses a single index position.

An array containing values:

  • When all values are requested.
  • When a range of values is requested by using the indexFrom and indexTo parameters.

An empty array if no elements exist in the specified list.

Examples

Return All Values

The example below returns all values from the "fruits" list.

Backendless.Hive("groceryStore").ListStore("fruits").get();

where:

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

Return Value By Index

The example below returns an item located at the index position 1 in the "fruits" list.

Backendless.Hive("groceryStore").ListStore("fruits").get(1);

where:

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

Return Range Of Values

The example below returns four values from the "fruits" list since the operation is set to retrieve all items in range starting from index position 2 to 5.

Backendless.Hive("groceryStore").ListStore("fruits").get(2, 5);

where:

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

Codeless Reference

list_api_get_key_items

where:

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

Returns a list containing values.

Consider the following List storage:

list_api_example_get_values_2

The example below returns all values from the "fruits" list.

list_api_example_get_key_items
The output will look as shown below after the Codeless logic runs.
list_api_example_get_items_by_range_3

You can also get an item by using the index position. Every value in a list is located at a specific index position. The operation accepts an index to return the value located in that position. List indexes are zero-based, it means the very first element in a List has the index of 0. However, you can also use a negative index, for instance -1 to return the last item from that list, -2 points to the second to last and so on. For more information about the indexes see the Hive Overview section of this guide.
list_api_get_key_item_by_index

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a list.
index An index position of the specified value.


The example below retrieves the value positioned in the index 1 in the "fruits" list.

list_api_example_get_key_items_by_index
The output will look as shown below after the Codeless logic runs.
list_api_example_get_items_by_range_4

This operation also allows getting a range of items:

list_api_get_key_items_by_range

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a list.
from Identifies the first value to get by index position
to Identifies the last value to get by index position

The example below returns two values from the "fruits" list since the operation is set to retrieve all items in range starting from index position 0 to 1.

list_api_example_get_items_by_range
The output will look as shown below after the Codeless logic runs.
list_api_example_get_items_by_range_2