Delete Values By Score Range¶
Description¶
This operation deletes all items with a score between the specified minimum and maximum boundaries.
Method¶
Backendless.Hive( hiveName ).SortedSetStore( keyName ).deleteValuesByScore( {
minScore: minScoreValue,
maxScore: maxScoreValue,
minBound: "minBoundValue",
maxBound: "maxBoundValue",
}): Promise<number>;
where:
Argument | Description |
---|---|
hiveName |
Name of a hive where the operation is performed. Must be a string value. |
keyName |
Key name identifying a sorted set. |
minScoreValue/maxScoreValue |
Minimum and maximum value of the scores to identify the items to delete. To control whether the specified score values are included or excluded from the range, use the minBound /maxBound parameters. |
"minBoundValue"/"maxBoundValue" |
Optional parameters. Available options are: "Include" - Includes value specified in the corresponding minScoreValue /maxScoreValue parameter into the range."Exclude" - Excludes value specified in the corresponding minScoreValue /maxScoreValue parameter from the range."Infinity" - Ignores the corresponding minScoreValue /maxScoreValue parameter and includes all consecutive score values that come before/after the defined score range. For example, if minBoundValue is set to "Infinity" and maxScore is set to 5, the query will include all values with scores less than 5. |
Return Value¶
The number of deleted items.
Example¶
The example below deletes all values in score range from 1
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('demoHive').SortedSetStore('leaderboard').deleteValuesByScore({
minScore: 0,
maxScore: 20,
minBound: 'Include',
maxBound: 'Exclude'
})
where:
Argument | Description |
---|---|
'demoHive' |
Name of a hive where the operation is performed. |
'leaderboard' |
Key name identifying a sorted set. |
Codeless Reference
¶
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 |
Minimum and maximum value of the scores to identify the items to delete. To control whether the specified score values are included or excluded from the range, use the min /max bound parameters. |
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 deleted items.
Consider the following Sorted Set storage:
The example below deletes all values in score range from 0
to 5
. Considering the sorted set (i.e. "players"
) presented above only two values are deleted since "Bobby"
has the score of 3
and "John"
has the score of 5
; These two values fall into the specified score range.
The sorted set will look as shown below after the Codeless logic runs.