Set Keys and Values¶
Description¶
This operation modifies values associated with one or more keys. If the specified keys do not exist, new key-value pairs are created.
Method¶
[[[Backendless.shared hive:(NSString *)hiveName] keyValueStore] setWithValues:(NSDictionary<NSString *,id> *)values responseHandler:^(void)responseHandler errorHandler:^(Fault *)errorHandler];
Backendless.shared.hive(hiveName: String).keyValueStore.set(values: [String : Any], responseHandler: (() -> Void)!, errorHandler: ((Fault) -> Void)!)
where:
Argument | Description |
---|---|
hiveName |
Name of a hive where the operation is performed. String value. |
values |
An object containing a mapping of keys and the corresponding values to be used as key-value pairs by the operation. |
Return Value¶
None.
Example¶
The example below modifies values associated with the keys "Japan"
and "USA"
. In case the keys do not exist, new key-value pairs are created.
[[[Backendless.shared hive:@"countries"] keyValueStore] setWithValues:@{@"Japan": @"The land of the rising sun", @"USA": @"The country of freedom"} responseHandler:^{
// handle response
} errorHandler:^(Fault *fault) {
// handle error
}];
Backendless.shared.hive("countries").keyValueStore.set(values: ["Japan": "The land of the rising sun", "USA": "The country of freedom"], responseHandler: {
// handle response
}, errorHandler: { fault in
// handle error
})
where:
Argument | Description |
---|---|
"countries" |
Name of a hive where the operation is performed. |
"Japan","USA" |
Keys to update the values of. If the keys do not exist, new key-value pairs are created. |
"The land of the rising sun","The country of freedom" |
Values to assign to the keys. |
Codeless Reference¶
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
keys/values object |
An object containing key names and corresponding values. |
Consider the following Key Value storage:
The following example sets key-value pairs:
The key-value storage will look as shown below after the Codeless logic runs: