Get Rank¶
Description¶
This operation returns the rank of a specific item from the sorted set. 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.
Method¶
Backendless.Hive(hiveName).SortedSetStore(keyName).getRank(member, reverse);
where:
Argument | Description |
---|---|
hiveName |
Name of a hive where the operation is performed. String value. |
keyName |
Key name identifying a sorted-set. String value. |
member |
The value identifying a score-value pair. |
reverse |
Optional parameter, defaults to false . A boolean value. When set to false , the returned items in the sorted-set are sorted in the ascending order. When set to true , the returned items are sorted in the descending order. |
Return Value¶
The rank of the specified item. Otherwise, returns the null
if the item does not exist.
Example¶
The example below returns the rank of the "\"Player A\""
item from the "players"
sorted set. Since the reverse
parameter is set to true
, the items in the sorted set are arranged in the descending order.
Backendless.Hive("leaderboard").SortedSetStore("players").getRank("\"Player A\"", true);
where:
Argument | Description |
---|---|
"leaderboard" |
Name of a hive in the system. |
"players" |
Name of a sorted set where the operation takes place. |
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 |
Value to get the rank of. Must be the same value/object/type as stored in the sorted set. |
reverse |
When set to true , items are sorted in ascending order. If set to false , items are ordered in descending order. |
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.
Returns the rank of the specified value. Returns null
if the value does not exist.
Consider the following Sorted Set storage:
The example below retrieves the rank of a value named "Julia"
.
The output will look as shown below after the Codeless logic runs: