SDK
SDK Javascript v7.x
2

# sadd

Adds members to a set of unique values stored at key.

If the destination set does not exist, it is created beforehand.

[Redis documentation]

# Arguments

Copied to clipboard!
sadd(key, values, [options]);

Arguments Type Description
key
string
Set key
values
string[]
Values to add
options
object
Optional query arguments

# options

The options arguments can contain the following option properties:

Property Type (default) Description
queuable
boolean (true)
If true, queues the request during downtime, until connected to Kuzzle again

# Resolve

Resolves to the number of successfully added members.

# Usage

Copied to clipboard!
try {
  // Prints: 2
  console.log(await kuzzle.ms.sadd('setfoo', ['foo', 'bar']));
  // Prints: 1
  console.log(await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz']));
  // Prints: [ 'foo', 'bar', 'baz' ]
  console.log(await kuzzle.ms.smembers('setfoo'));
} catch (error) {
  console.error(error.message);
}