Add First¶
Description¶
This operation adds new values to the very beginning of a list.
Method¶
Add One Value
Backendless.Hive(hiveName).ListStore(keyName).addFirstValue(value): Promise<number>;
Add Multiple Values
Backendless.Hive(hiveName).ListStore(keyName).addFirstValues(values): Promise<number>;
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 JavaScript data type. |
values |
An array of values to add to the list. Individual values can be of any JavaScript data type. |
Return Value¶
The number of values in the list after the new values are saved.
Examples¶
Add a Single Value
The example below adds the new value 'Apples'
to the very beginning of the 'fruits'
list.
await Backendless.Hive('demoHive').ListStore('fruits').addFirstValue('Apples')
where:
Argument | Description |
---|---|
'demoHive' |
Name of a hive where the operation is performed. |
'fruits' |
Key name identifying a list. |
Add Multiple Values
The example below adds two values 'Apples'
,'Oranges'
to the very beginning of the 'fruits'
list.
await Backendless.Hive('demoHive').ListStore('fruits').addFirstValues(['Apples', 'Oranges'])
where:
Argument | Description |
---|---|
'demoHive' |
Name of a hive where the operation is performed. |
'fruits' |
Key name identifying a list. |
Codeless Reference
¶
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:
The example below adds "Pears"
and "Grapes"
to the beginning of the list:
After the codeless logic runs, the list in Hive contains the following data: