SDK
SDK Javascript v5.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.

scan #

Iterates incrementally over the set of keys in the database using a cursor.

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

[Redis documentation]


scan(cursor, [options], callback) #

ArgumentsTypeDescription
cursorintPage number (iteration starts with a cursor value of 0, and ends when the next cursor position is 0)
optionsJSON ObjectOptional parameters
callbackfunctionCallback

Options #

OptionTypeDescriptionDefault
countintReturn the approximate count number of items per result page10
matchstringSearch only for field names matching the provided pattern*
queuablebooleanMake this request queuable or nottrue

Callback Response #

Returns a JSON object containing 2 entries:

  • the cursor position for the next page of results (a next position of 0 indicates the end of the scan)
  • a list of fetched keys

Usage #

// Using callbacks (NodeJS or Web Browser)
kuzzle.memoryStorage.scan(0, function (err, page) {
  // callback called once the action has completed
});
// Using promises (NodeJS only)
kuzzle.memoryStorage.scanPromise(0)
  .then(page => {
    // resolved once the action has completed
  });

Callback response:

{
  "cursor": 18,
  "values": ["key1", "key2", "..."]
}