Skip to content

Decrement

Description

This operation decrements the key's value by a specific number.

Method

[[[Backendless.shared hive:(NSString *)hiveName] keyValueStore:(NSString *)keyName] decrementWithValue:(NSInteger)value responseHandler:^(NSInteger)responseHandler errorHandler:^(Fault *)errorHandler];
Backendless.shared.hive(hiveName: String).keyValueStore(keyName: String).decrement(value: 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 key-value pair. String value.
value A number to decrement the value of the key.

Return Value

Тhe decremented value.

Example

The example below decrements the value associated with the key "John" by 2.

[[[Backendless.shared hive:@"workedHours"] keyValueStore:@"John"] decrementWithValue:2 responseHandler:^(NSInteger response) {
    // handle response
} errorHandler:^(Fault *fault) {
    // handle error
}];
Backendless.shared.hive("workedHours").keyValueStore("John").decrement(value: 2, responseHandler: { response in
    // handle response
}, errorHandler: { fault in
    // handle error
})

where:

Argument                Description
"workedHours" Name of a hive where the operation is performed.
"John" Key name to decrement the associated value by 2.

Codeless Reference

keyvalue_api_decrement

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a key-value pair.
decrement by Specify a number to decrement the value by.

Returns the decremented value.

Consider the following Key Value storage:

keyvalue_api_example_increment_decrement

The example below decrements the value for the "Apples" key by 2:

keyvalue_api_example_decrement


The key-value storage will look as shown below after the Codeless logic runs:
keyvalue_api_example_decrement_2