Skip to content

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

PUT

Endpoint URL

Important

Make sure to replace xxxx in the domain name in the request specification below to the one assigned to your application.

https://xxxx.backendless.app/api/hive/[hive-name]/[bucket-type]/[key]/rename?newKey=[new-name]&overwrite=[overwrite]

where:

Argument                Description
[hive-name] Name of a hive where the operation is performed.
[bucket-type] Storage type in the[hive-name] Hive where the key is renamed. Acceptable values are list, key-value, map, set or sorted-set.
[key] Key name to rename.
[new-name] New name for the key.
[overwrite] When set to true, forces the rename operation and name overwrite if [new-name] already exists in the store. Defaults to true.

Request Headers

None.

Request Body

None.

Response Body

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.

curl --location --request PUT "https://xxxx.backendless.app/api/hive/groceryStore/list/fruits/rename?newKey=fruitsAndBerries"

where:

Argument                Description
groceryStore Name of a hive where the operation is performed.
fruits Key name in the store.
fruitsAndBerries New name of the fruits key.


Codeless Reference
general_api_rename_key

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:

sample-key-value

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

general_api_example_rename_key

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

rename-key-result