From ab220487a0a3a32c943c84e7023ab6438ad02ac5 Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Thu, 30 Mar 2023 18:47:20 +0200 Subject: [PATCH 1/2] test: add argument to unlink --- pkg/pipeline.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/pipeline.test.ts b/pkg/pipeline.test.ts index bcb9aa31..8f6ad3b2 100644 --- a/pkg/pipeline.test.ts +++ b/pkg/pipeline.test.ts @@ -195,7 +195,7 @@ Deno.test("use all the things", async (t) => { .touch(newKey()) .ttl(newKey()) .type(newKey()) - .unlink() + .unlink(newKey()) .zadd(newKey(), { score: 0, member: "member" }) .zcard(newKey()) .scriptExists(scriptHash) From a579fae4824717046e2a3364d80b2ad7bb729859 Mon Sep 17 00:00:00 2001 From: chronark Date: Mon, 1 May 2023 17:12:31 +0200 Subject: [PATCH 2/2] feat(hdel): add support for deleting multiple fields at once --- pkg/commands/hdel.test.ts | 21 +++++++++++++++++++++ pkg/commands/hdel.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pkg/commands/hdel.test.ts b/pkg/commands/hdel.test.ts index ed72da12..9c7419f3 100644 --- a/pkg/commands/hdel.test.ts +++ b/pkg/commands/hdel.test.ts @@ -36,3 +36,24 @@ Deno.test( assertEquals(res2, null); }, ); + +Deno.test( + "deletes multiple fields", + async () => { + const key = newKey(); + const field1 = randomID(); + const field2 = randomID(); + await new HSetCommand([key, { [field1]: randomID(), [field2]: randomID() }]) + .exec( + client, + ); + const res = await new HDelCommand([key, field1, field2]).exec(client); + + assertEquals(res, 2); + const res2 = await new HGetCommand([key, field1]).exec(client); + assertEquals(res2, null); + + const res3 = await new HGetCommand([key, field2]).exec(client); + assertEquals(res3, null); + }, +); diff --git a/pkg/commands/hdel.ts b/pkg/commands/hdel.ts index ad5084b0..ca571bcc 100644 --- a/pkg/commands/hdel.ts +++ b/pkg/commands/hdel.ts @@ -5,7 +5,7 @@ import { Command, CommandOptions } from "./command.ts"; */ export class HDelCommand extends Command<"0" | "1", 0 | 1> { constructor( - cmd: [key: string, field: string], + cmd: [key: string, ...fields: string[]], opts?: CommandOptions<"0" | "1", 0 | 1>, ) { super(["hdel", ...cmd], opts);