Skip to content

Commit

Permalink
feat(HscanStream): adding NOVALUES option
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Zambrano committed Jan 7, 2025
1 parent 1d425da commit 28fb557
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
5 changes: 4 additions & 1 deletion lib/ScanStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface Options extends ReadableOptions {
command: string;
redis: any;
count?: string | number;
noValues?: boolean;
}

/**
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export interface ScanStreamOptions {
match?: string;
type?: string;
count?: number;
}
noValues?: boolean;
}

0 comments on commit 28fb557

Please sign in to comment.