From 28fb55709055aca3cc0078f9e2d919111b2babb7 Mon Sep 17 00:00:00 2001 From: Nicolas Zambrano Date: Tue, 7 Jan 2025 10:49:27 +0100 Subject: [PATCH] feat(HscanStream): adding NOVALUES option --- README.md | 8 +++++++- lib/ScanStream.ts | 5 ++++- lib/types.ts | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9881f3ce..526502a8 100644 --- a/README.md +++ b/README.md @@ -722,12 +722,18 @@ the key names are not utf8 strings. There are also `hscanStream`, `zscanStream` and `sscanStream` to iterate through elements in a hash, zset and set. The interface of each is similar to `scanStream` except the first argument is the key name: +```javascript +const stream = redis.zscanStream("myhash", { + match: "age:??", +}); +``` +Also `hscanStream` accept noValues option (true or false) ```javascript const stream = redis.hscanStream("myhash", { match: "age:??", + noValues: true, }); ``` - You can learn more from the [Redis documentation](http://redis.io/commands/scan). **Useful Tips** diff --git a/lib/ScanStream.ts b/lib/ScanStream.ts index e74a7a2c..46816753 100644 --- a/lib/ScanStream.ts +++ b/lib/ScanStream.ts @@ -7,6 +7,7 @@ interface Options extends ReadableOptions { command: string; redis: any; count?: string | number; + noValues?: boolean; } /** @@ -39,7 +40,9 @@ export default class ScanStream extends Readable { if (this.opt.count) { args.push("COUNT", String(this.opt.count)); } - + if (this.opt.noValues) { + args.push("NOVALUES"); + } this.opt.redis[this.opt.command](args, (err, res) => { if (err) { this.emit("error", err); diff --git a/lib/types.ts b/lib/types.ts index 8c897a8e..34b0a421 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -30,4 +30,5 @@ export interface ScanStreamOptions { match?: string; type?: string; count?: number; -} + noValues?: boolean; +} \ No newline at end of file