Insert Before¶
Description¶
This operation inserts a new value before an existing value in a list.
Method¶
Backendless.Hive(hiveName).ListStore(keyName).insertBefore(valueToInsert, anchorValue): 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. |
valueToInsert |
New value to insert into the list. Can be of any JavaScript data type. |
anchorValue |
Value which is used as a position anchor. Must be a value that already exists in the list. |
Return Value¶
The number of values in the list after the insertion operation.
Example¶
The example below inserts the value 'red'
before 'blue'
in the 'colors'
list.
await Backendless.Hive('demoHive').ListStore('colors').insertBefore('red', 'blue')
where:
Argument | Description |
---|---|
'demoHive' |
Name of a hive where the operation is performed. |
'colors' |
Key name identifying a list where the new value is inserted. |
Codeless Reference¶
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
key name |
Key name identifying a list. |
item |
New item to insert into the list. |
before item |
Value which is used as a position anchor. |
Returns he number of values in the list after the insertion operation.
Consider the following List storage:
The example below inserts the value "Ann"
before "Bobby"
in a list identified by the "testList"
key name: