Skip to content

What is the proper way of using HDEL with an array of fields? #369

@da99

Description

@da99

Is HDEL supposed to be used as the following?:

client.hdel( my_key, [ field1, field2, ...] , callback );

or:

client.hdel( [ my_key, field1, field2, ...] , callback );

Right now, with node-redis 0.8.2, (no hiredis), the second approach works perfectly, The first approach only works with an array of length 1: [ field1 ]. Is this the correct behaviour? Or should it be the first approach?

Here is a more complete code example:

var redis = require("redis"),
client = redis.createClient();

client.hmset("my_hash", {a: "a", b: "b"}, function (e, r) {
  redis.print(e,r);
  client.hmset("my_hash", {c: "c", d: "d"}, function (e, r) {
    redis.print(e,r);
    client.hdel('my_hash', ['a', 'c', 'd'], function (e, r) {

      redis.print(e,'This does not work: instead of 3 we get: ' + r);
      client.hdel("my_hash", 'a', 'c', 'd', function (e, r) {
        redis.print(e,'We get what we want using this approach: ' + r);
        client.quit();
      });
    });
  });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions