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¶
// overwrite parameter = false by default
[[[Backendless.shared hive:(NSString *)hiveName] storeType:(NSString *)keyName] renameWithNewKeyName:(NSString *)newKeyName responseHandler:^(BOOL)responseHandler errorHandler:^(Fault *)errorHandler];
// with overwrite parameter
[[[Backendless.shared hive:(NSString *)hiveName] storeType:(NSString *)keyName] renameWithNewKeyName:(NSString *)newKeyName overwrite:(BOOL)overwrite responseHandler:^(BOOL)responseHandler errorHandler:^(Fault *)errorHandler];
// overwrite parameter = false by default
Backendless.shared.hive(hiveName: String).storeType(keyName: String).rename(newKeyName: String, responseHandler: ((Bool) -> Void)!, errorHandler: ((Fault) -> Void)!)
// with overwrite parameter
Backendless.shared.hive(hiveName: String).storeType(keyName: String).rename(newKeyName: String, overwrite: Bool, responseHandler: ((Bool) -> Void)!, errorHandler: ((Fault) -> Void)!)
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 . |
keyName |
Key name to rename. String value. |
newKeyName |
New name for the key. String value. |
overwrite |
When set to true , forces the rename operation and name overwrite if newKeyName already 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.shared hive:@"groceryStore"] listStore:@"fruits"] renameWithNewKeyName:@"fruitsAndBerries" overwrite:true responseHandler:^(BOOL response) {
// handle response
} errorHandler:^(Fault *fault) {
// handle error
}];
Backendless.shared.hive("groceryStore").listStore("fruits").rename(newKeyName: "fruitsAndBerries", overwrite: true, responseHandler: { response in
// handle response
}, errorHandler: { fault in
// handle error
})
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: