Delete Values With Min Score¶
Description¶
This operation retrieves and deletes items with the lowest scores from the sorted set. You can specify the number of values to retrieve and delete.
Method¶
[[[Backendless.shared hive:(NSString *)hiveName] sortedSetStore:(NSString *)keyName]] getAndDeleteMinScoreWithCount:(NSInteger)count responseHandler:^(NSArray<SortedSetItem *> *)responseHandler errorHandler:^(Fault *)errorHandler];
Backendless.shared.hive(hiveName: String).sortedSetStore(keyName: String).getAndDeleteMinScore(count: Int, responseHandler: (([SortedSetItem]) -> Void)!, errorHandler: ((Fault) -> Void)!)
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 lowest score from a sorted set.
[[[Backendless.shared hive:@"leaderboard"] sortedSetStore:@"players"] getAndDeleteMinScoreWithCount:5 responseHandler:^(NSArray<SortedSetItem *> *response) {
// handle response
} errorHandler:^(Fault *fault) {
// handle error
}];
Backendless.shared.hive("leaderboard").sortedSetStore("players").getAndDeleteMinScore(count: 5, responseHandler: { response in
// handle response
}, errorHandler: { fault in
// handle error
})
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¶
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 items to delete from the sorted set. |
Returns a list of the deleted score-value pairs.
Consider the following Sorted Set storage:
The example below deletes one value with the minimum score from the "players"
sorted set. Considering the sorted set presented above, the value "Bobby"
is deleted since it has the lowest score.
The sorted set will look as shown below after the Codeless logic runs.