Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pkg/commands/hdel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
);
2 changes: 1 addition & 1 deletion pkg/commands/hdel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down