SDK
SDK Javascript v7.x
2

sscan #

Iterates incrementally over members contained in a set of unique values, using a cursor.

An iteration starts when the cursor is set to 0.
To get the next page of results, simply re-send the request with the updated cursor position provided in the result set.

The scan ends when the cursor returned by the server is 0.

[Redis documentation]

Arguments #

sscan(key, cursor, [options]);

ArgumentsTypeDescription
key
string
Set key
cursor
integer
Cursor offset
options
object
Optional query arguments

options #

The options arguments can contain the following option properties:

PropertyType (default)Description
count
integer (10)
Return an approximate number of items per result set
match
string (*)
Return only keys matching the provided pattern
queuable
boolean (true)
If true, queues the request during downtime, until connected to Kuzzle again
timeout
number

(-1)
Time (in ms) during which a request will still be waited to be resolved. Set it -1 if you want to wait indefinitely
triggerEvents
boolean

(false)
If set to true, will trigger events even if using Embeded SDK. You should always ensure that your events/pipes does not create an infinite loop.
Available since Kuzzle 2.31.0

Resolve #

Resolves to an object representing a result page, with the following properties:

PropertyTypeDescription
cursor
integer
Cursor offset for the next page, or 0 if at the end of the scan
values
string[]
List of found members

Usage #

try {
  await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz']);
  // Prints:
  // {
  //   cursor: '0',
  //   values: [ bar', 'baz' ]
  // }
  console.log(await kuzzle.ms.sscan('setfoo', 0, {match: 'ba*'}));
} catch (error) {
  console.error(error.message);
}