Rename Key¶
Description¶
This operation renames a key. The corresponding value is not impacted. After the operation is complete, the value is available with the new key name.
Method¶
Backendless.Hive(hiveName).StoreType(key).rename(newKey, overwrite);
where:
| Argument | Description |
|---|---|
hiveName |
Name of a hive where the operation is performed. String value. |
StoreType |
This placeholder must be substituted with one of the following stores types: KeyValueStore, ListStore, MapStore, SetStore, SortedSetStore. |
key |
Key name to rename. String value. |
newKey |
New name for the key. String value. |
overwrite |
When set to true, forces the rename operation and name overwrite if newKeyalready exists in the store.Defaults to true. Boolean value. |
Return Value¶
true if the specified key is renamed. Otherwise returns false.
If the specified key does not exist, then the following Backendless error is returned:
{
"code": 27003,
"message": "no such key",
"errorData": {}
}
Example¶
The example below renames the "fruits" key to "fruitsAndBerries".
Backendless.Hive("groceryStore").ListStore("fruits").rename("fruitsAndBerries", true);
where:
| Argument | Description |
|---|---|
"groceryStore" |
Name of a hive where the operation is performed. |
"fruits" |
Key name to rename |
"fruitsAndBerries" |
New key name in the store. |
Codeless Reference
¶
where:
| Argument | Description |
|---|---|
hive name |
Name of a hive where the operation is performed. |
type |
Storage type, can be one of the following: Key / Value, Sorted Set, Set, Map, List. |
key name |
Key name to rename. |
new name |
New name to assign to a key. |
overwrite |
When set to true, forces the rename operation and name overwrite if [new-name] already exists in the store. Defaults to true. |
Returns true if the specified key is renamed. Otherwise, returns false.
Consider the following Key Value storage:

The following example renames the "Japan" key in the storage:

Once the operation is performed, the storage will have the data as shown below:
