Skip to content

Get Score

Description

This operation returns the score of a value from a sorted set.

Method

Backendless.Hive( hiveName ).SortedSetStore( keyName ).getScore( value ): Promise<number | null>;

where:

Argument                Description
hiveName Name of a hive in the system where the operation is performed. Must be a string.
keyName Key name identifying a sorted set.
value Value to get the score of.

Return Value

The score of an item as a number value. Returns null if the value does not exist in the sorted set.

Example

The example below returns the score of the 'JoeTheGamer' item from the 'leaderboard' sorted set.

await Backendless.Hive('demoHive').SortedSetStore('leaderboard').getScore('JoeTheGamer')

where:

Argument                Description
'demoHive'  Name of a hive where the operation is performed.
'leaderboard'  The name of the sorted set to return a score associated with the specified value.
'JoeTheGamer' Value to get the score of.


Codeless Reference
sorted_set_api_get_score

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a sorted set.
value Value to get the score of.

Returns the score of an item. Returns null if the value does not exist in the sorted set.

Consider the following Sorted Set storage:
sorted_set_api_example_all_blocks

The example below retrieves the score of a value "Julia" from the "players" sorted set:
sorted_set_api_example_get_score

The output will look as shown below after the Codeless logic runs:
sorted_set_api_example_get_score_2