Increment Score¶
Description¶
This operation increments the score of an item by the specified number.
Method¶
Backendless.Hive( hiveName ).SortedSetStore( keyName ).incrementScore( value, scoreValue ): Promise<number>;
where:
Argument | Description |
---|---|
hiveName |
Name of a hive in the system where the operation is performed. Must be a string. |
keyName |
Key name of a sorted set where a score is incremented. Must be a string. |
value |
An exact value as one already in the sorted set. The value identifies a score/value pair. The score of the corresponding value in the sorted set will be incremented by the number in the scoreValue parameter. The value can be of any valid JS data type. |
scoreValue |
A number that the existing score will be incremented by. Must be a double value. |
Return Value¶
The incremented score of an item.
Example¶
The example below increments the score associated with the value "John"
by 3
.
await Backendless.Hive('leaderboard').SortedSetStore('players').incrementScore('John', 3)
where:
Argument | Description |
---|---|
'leaderboard' |
Name of a hive in the system. |
'players' |
Key name of a sorted set where to increment the score of an item. |
Codeless Reference¶
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
key name |
Key name identifying a sorted set. |
value |
An exact value as one already in the sorted set. The value identifies a score/value pair. The score of the corresponding value in the sorted set will be incremented by the number in the increment by parameter. |
increment by |
Specify the number to increment the score of the value. |
The operation returns the modified incremented score of an item.
Consider the following Sorted Set storage:
The example below increments the score of a value "John"
by 3
:
The output will look as shown below after the Codeless logic runs.
Note how the incremented score forced the score/value pair to change its current position(rank). Before the operation the rank of the "John"
value was 1
, and after the operation the rank became 2
.
Rank in a sorted set determines the position of an element. For more information about the rank, refer to the Hive Overview section of this guide.