|
5 | 5 | import { |
6 | 6 | ExpireOptions, |
7 | 7 | InfoOptions, |
| 8 | + ScoreLimit, |
8 | 9 | SetOptions, |
9 | 10 | ZaddOptions, |
10 | 11 | createClientGetName, |
@@ -56,6 +57,7 @@ import { |
56 | 57 | createUnlink, |
57 | 58 | createZadd, |
58 | 59 | createZcard, |
| 60 | + createZcount, |
59 | 61 | createZrem, |
60 | 62 | createZscore, |
61 | 63 | } from "./Commands"; |
@@ -833,8 +835,24 @@ export class BaseTransaction<T extends BaseTransaction<T>> { |
833 | 835 | * If `key` does not exist, null is returned. |
834 | 836 | * If `key` holds a value that is not a sorted set, an error is returned. |
835 | 837 | */ |
836 | | - public zscore(key: string, member: string) { |
837 | | - this.commands.push(createZscore(key, member)); |
| 838 | + public zscore(key: string, member: string): T { |
| 839 | + return this.addAndReturn(createZscore(key, member)); |
| 840 | + } |
| 841 | + |
| 842 | + /** Returns the number of members in the sorted set stored at `key` with scores between `minScore` and `maxScore`. |
| 843 | + * See https://redis.io/commands/zcount/ for more details. |
| 844 | + * |
| 845 | + * @param key - The key of the sorted set. |
| 846 | + * @param minScore - The minimum score to count from. Can be positive/negative infinity, or specific score and inclusivity. |
| 847 | + * @param maxScore - The maximum score to count up to. Can be positive/negative infinity, or specific score and inclusivity. |
| 848 | + * |
| 849 | + * Command Response - The number of members in the specified score range. |
| 850 | + * If `key` does not exist, it is treated as an empty sorted set, and the command returns 0. |
| 851 | + * If `minScore` is greater than `maxScore`, 0 is returned. |
| 852 | + * If `key` holds a value that is not a sorted set, an error is returned. |
| 853 | + */ |
| 854 | + public zcount(key: string, minScore: ScoreLimit, maxScore: ScoreLimit): T { |
| 855 | + return this.addAndReturn(createZcount(key, minScore, maxScore)); |
838 | 856 | } |
839 | 857 |
|
840 | 858 | /** Executes a single command, without checking inputs. Every part of the command, including subcommands, |
|
0 commit comments