Set Values¶
Description¶
This operation updates a value for a key if it exists. In case the specified key does not exist, then a new key-value pair is added.
Method¶
[[[Backendless.shared hive:(NSString *)hiveName] mapStore:(NSString *)keyName] setWithData:(NSDictionary<NSString *,id> *)data responseHandler:^(NSInteger)responseHandler errorHandler:^(Fault *)errorHandler];
Backendless.shared.hive(hiveName: String).mapStore(keyName: String).set(data: [String : Any], responseHandler: ((Int) -> Void)!), errorHandler: ((Fault) -> Void)!)
where:
Argument | Description |
---|---|
hiveName |
Name of a hive where the operation is performed. String value. |
keyName |
Key name identifying a map. String value. |
data |
Key-value pairs that must be added to the map. Keys must be of the string type, and values of any data type. |
Return Value¶
The number of newly added key-value pairs.
Example¶
The example below adds new key-value pairs "Pineapples":1.99
and "Grapes":1.49
to the "fruits"
map.
[[[Backendless.shared hive:@"groceryStore"] mapStore:@"fruits"] setWithData:@{@"Pineapples": @1.99, @"Grapes": @1.49} responseHandler:^(NSInteger response) {
// handle response
} errorHandler:^(Fault *fault) {
// handle error
}];
Backendless.shared.hive("groceryStore").mapStore("fruits").set(data: ["Pineapples": 1.99, "Grapes": 1.49], 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 identifying a map. |
Codeless Reference¶
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
key name |
Key name identifying a map. |
values(object) |
An object containing key-value pairs that must be added to the map. |
Returns the number of newly added key-value pairs.
Consider the following Map storage:
The example below adds new key-value pairs "Pineapples":1.99
and "Grapes":1.49
to the "fruits"
map.
The map will look as shown below after the Codeless logic runs: