Decrement¶
Description¶
This operation decrements the value of the specified key by a specific number.
Method¶
[[[Backendless.shared hive:(NSString *)hiveName] mapStore:(NSString *)keyName] decrementWithKey:(NSString *)key count:(NSInteger)count responseHandler:^(NSInteger)responseHandler errorHandler:^(Fault *)errorHandler];
Backendless.shared.hive(hiveName: String).mapStore(keyName: String).decrement(key: String, count: Int, 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. |
key |
Key name identifying a key-value pair. String value. |
count |
Specify the number to decrement the value of the specified key. |
Return Value¶
The decremented value.
Examples¶
Decrement The Value By n - 1
The example below decrements the value of the "Apples"
key by 1
. When this operation is used without the count
parameter, then the value is always decremented by 1
for every query made.
[[[Backendless.shared hive:@"groceryStore"] mapStore:@"fruits"] decrementWithKey:@"Apples" responseHandler:^(NSInteger response) {
// handle response
} errorHandler:^(Fault *fault) {
// handle error
}];
Backendless.shared.hive("groceryStore").mapStore("fruits").decrement(key: "Apples", 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. |
Decrement The Value By A Number
The example below decrements the value of the "Apples"
key by 3
.
[[[Backendless.shared hive:@"groceryStore"] mapStore:@"fruits"] decrementWithKey:@"Apples" count:3 responseHandler:^(NSInteger response) {
// handle response
} errorHandler:^(Fault *fault) {
// handle error
}];
Backendless.shared.hive("groceryStore").mapStore("fruits").decrement(key: "Apples", count: 3, 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. |
object key name |
Key name identifying a key-value pair. |
decrement by |
Specify the number to decrement the value of the specified key. |
Returns the decremented value.
Consider the following Map storage:
The example below decrements the value of the key "Apples"
by 3
.
The map will look as shown below after the Codeless logic runs: