Skip to content

Length with a Query

Description

This operation returns the number of items with a score a range between the specified min and max values.

Method

Backendless.Hive( hiveName ).SortedSetStore( keyName ).deleteValuesByScore( {
   minScore: number,
   maxScore: number,
   minBound: string,
   maxBound: string,
}): Promise<number>;

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a sorted-set. String value.

Return Value

Number of items with a score and range between the specified min and max values.

Example

The example gets the count of items with scores between 1 and to 20. The minBound parameter is Include, as a result the score of 1 is included in the range. The maxBound parameter is set to Exclude, as a result, the value of 20 is excluded from the range.

await Backendless.Hive('hiveName').SortedSetStore('leaderboard').countBetweenScores({
  minScore: 0,
  maxScore: 20,
  minBound: 'Include',
  maxBound: 'Exclude'
})

where:

Argument                Description
'leaderboard'  Name of a hive where the operation is performed.
'players'  Key name identifying a sorted set.

Codeless Reference

sorted_set_api_get_count_with_a_query

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a sorted set.
min/max score Specify the minimum and maximum score values to form a range. Refer to description above.
min/max bound Parameters that control the presence of the first and last values in the range. Each parameter has three options:

Include - Includes value specified in the corresponding min score/max score parameter into the range.

Exclude - Excludes value specified in the corresponding min score/max score parameter from the range.

Infinity - Ignores the corresponding min score/max score parameter and includes all consecutive score values that come before/after the defined score range. For example, if min bound is set to Infinity and max score is set to 5, the query will include all values with scores less than 5.

These parameters default to Include.

Returns the number of items with a score and range between the specified min and max values.

Consider the following Sorted Set storage:
sorted_set_api_example_all_blocks

The example below retrieves the count of items with scores between 0 and to 5. Considering the sorted set (i.e. "players") presented above only two values are counted since "Bobby" has the score of 3 and "John" has the score of 5; These two values fall into the specified score range.
sorted_set_api_example_get_count_with_a_query


The output will look as shown below after the Codeless logic runs.
sorted_set_api_example_get_count_with_a_query_2