SDK
SDK Javascript v6.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

zscan #

Iterates incrementally over members contained in a sorted set, 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 #

Copied to clipboard!
zscan(key, cursor, [options]);

Arguments Type Description
key
string
Sorted set key
cursor
integer
Cursor offset
options
object
Optional query arguments

options #

The options arguments can contain the following option properties:

Property Type (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

Resolve #

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

Property Type Description
cursor
integer
Cursor offset for the next page, or 0 if at the end of the scan
values
string[]
List of member-score pairs. The array entries alternate between member values and their associated scores

Usage #

Copied to clipboard!
try {
  await kuzzle.ms.zadd('ssetfoo', [
    {member: 'foo', score: '42'},
    {member: 'bar', score: '4'},
    {member: 'baz', score: '-272.15'}
  ]);
  // Prints:
  // {
  //   cursor: '0',
  //   values: [ 'baz', '-272.15', 'bar', '4', 'foo', '42' ]
  // }
  console.log(await kuzzle.ms.zscan('ssetfoo', 0));
} catch (error) {
  console.error(error.message);
}