Skip to content

Decrement

Description

This operation decrements the value of the specified key by a specific number.

Method

PUT

Endpoint URL

Important

Make sure to replace xxxx in the domain name in the request specification below to the one assigned to your application.

https://xxxx.backendless.app/api/hive/[hive-name]/map/[key]/decrement/[key-name]?count=[decrement-by] 

where:

Argument                Description
[hive-name] Name of a hive where the operation is performed.
[key] Key name identifying a map.
[key-name] Key name identifying a key-value pair.
[decrement-by] A number to decrement a value by. Defaults to 1.

Request Headers

Content-Type:application/json

where:

Argument                Description
Content-Type Must be set to application/json. This header is mandatory.

Request Body

None.

Response Body

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.

curl --location --request PUT "https://xxxx.backendless.app/api/hive/groceryStore/map/fruits/decrement/Apples"

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.

curl --location --request PUT "https://xxxx.backendless.app/api/hive/groceryStore/map/fruits/decrement/Apples?count=3"

where:

Argument                Description
groceryStore Name of a hive where the operation is performed.
fruits Key name identifying a map.

Codeless Reference

map_api_decrement

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:
map_apI_example_map_store_6

The example below decrements the value of the key "Apples" by 3.

map_api_example_decrement

The map will look as shown below after the Codeless logic runs:
map_apI_example_map_store_8