SDK
SDK Javascript v7.x
2

hmset #

Sets multiple fields at once in a hash.

[Redis documentation]

Arguments #

hmset(key, entries, [options]);

ArgumentsTypeDescription
key
string
Hash key
entries
object[]
List of field-value pairs to set
options
object
Optional query arguments

entries #

The entries array lists the fields to set in the hash. Each entry object has the following properties:

PropertiesTypeDescription
field
string
Field name
value
string
Field value

options #

The options arguments can contain the following option properties:

PropertyType (default)Description
queuable
boolean (true)
If true, queues the request during downtime, until connected to Kuzzle again
[triggerEvents](/sdk/7/core-classetimeout
number

(-1)

Resolve #

Resolves once the fields have been set.

Usage #

try {
  await kuzzle.ms.hmset(
    'hashfoo',
    [
      {field: 'key1', value: 'val1'},
      {field: 'key2', value: 'val2'},
      {field: 'key3', value: 'val3'}
    ]
  );
  // Prints: { key1: 'val1', key2: 'val2', key3: 'val3' }
  console.log(await kuzzle.ms.hgetall('hashfoo'));
} catch (error) {
  console.error(error.message);
}