Arjun Bajaj
Arjun Bajaj

Reputation: 1972

HDEL, HSET not working in NodeJS

can anyone tell me what is wrong in this code?

redis.hdel("hash:" + id + " key" function(err, success) {
    console.log("Hash Deleted");
});

Is there any other way to do it?

And I'm also struggling with HSET:

redis.hset("hash:" + id + " key", "true");

It tells me "wrong number of arguments". What more is it expecting? In the Redis documentation of HSET, there are no more parameters.

So I used HMSET instead, and it works properly. :)

Also, if anyone can tell me, some source where I can find examples of all commands or at least all the hash commands in NodeJS.

Thanks.

Upvotes: 6

Views: 23094

Answers (1)

Michelle Tilley
Michelle Tilley

Reputation: 159105

HSET takes three parameters, key, field, value. HDEL takes two, key and field. Have you tried, as per the readme:

client.hset("key", "field", "value", callback);

Similarly,

client.hdel("key", "field", callback);

Upvotes: 18

Related Questions