Skip to content

Delete Values With Max Score

Description

This operation retrieves and deletes items with the highest scores from the sorted set. You can specify the number of values to retrieve and delete.

Method

Backendless.Hive( hiveName ).SortedSetStore( keyName ).getAndDeleteMaxScore( count ): Promise<items>;

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a sorted-set. String value.
count Optional parameter, if not present, defaults to 1. Number of values to delete from the sorted set.

Return Value

An array containing deleted score-value pairs.

Example

The example below deletes two items with the highest score from the sorted set.

await Backendless.Hive('leaderboard').SortedSetStore('players').getAndDeleteMaxScore(2)

where:

Argument                Description
'leaderboard' Name of a hive in the system.
'players' Name of a sorted set to retrieve and delete score-value pairs from.

Codeless Reference

sorted_set_api_delete_values_with_max_score

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a sorted set.
count Specify the number of values to delete from the sorted set.

Returns a list of the deleted score-value pairs.

Consider the following Sorted Set storage:
sorted_set_api_example_all_blocks

The example below deletes one value with the maximum score from the "players" sorted set. Considering the sorted set presented above, the value "Julia" is deleted since it has the highest score.
sorted_set_api_example_delete_values_with_max_score

The sorted set will look as shown below after the Codeless logic runs.
sorted_set_api_example_delete_values_with_max_score_2