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.

hscan #

Iterates incrementally over fields contained in a hash, 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 #

hscan(key, cursor, [options]);

ArgumentsTypeDescription
key
string
Hash 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

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 field-value pairs, alternating field names and values

Usage #

try {
  await kuzzle.ms.hset('hashfoo', 'key1', 'val1');
  await kuzzle.ms.hset('hashfoo', 'key2', 'val2');
  await kuzzle.ms.hset('hashfoo', 'key3', 'val3');
  // Prints:
  // {
  //   cursor: '0',
  //   values: [ 'key1', 'val1', 'key2', 'val2', 'key3', 'val3' ]
  // }
  console.log(await kuzzle.ms.hscan('hashfoo', 0));
} catch (error) {
  console.error(error.message);
}