SDK
SDK Javascript v7.x
2

lrange #

Returns the list elements between the start and stop positions.

Offsets start at 0, and the range is inclusive.

[Redis documentation]

Arguments #

Copied to clipboard!
lrange(key, start, stop, [options]);

Arguments Type Description
key
string
List key
start
integer
Starting index (inclusive)
stop
integer
Ending index (inclusive)
options
object
Optional query arguments

The start and stop arguments can be negative. In that case, the offset is calculated from the end of the list, going backward. For instance, -3 is the third element from the end of the list.

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 an array of list elements.

Usage #

Copied to clipboard!
try {
  await kuzzle.ms.rpush('listfoo', ['a', 'b', 'c', 'd', 'e', 'f']);
  // Prints: [ 'b', 'c', 'd' ]
  console.log(await kuzzle.ms.lrange('listfoo', 1, 3));
  // Prints: [ d', 'e' ]
  console.log(await kuzzle.ms.lrange('listfoo', 3, -2));
} catch (error) {
  console.error(error.message);
}