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.

zrange #

Returns elements from a sorted set depending on their position in the set, from a start position index to a stop position index (inclusives).
First position starts at 0.

[Redis documentation]


zrange(key, start, stop, [options], [callback]) #

ArgumentsTypeDescription
keystringKey identifier
startintStart position in the set (index starts at position 0)
stopintEnd position in the set
optionsJSON ObjectOptional parameters
callbackfunctionCallback

Options #

OptionTypeDescriptionDefault
queuablebooleanMake this request queuable or nottrue

Return Value #

Returns the MemoryStorage object to allow chaining.


Callback Response #

Returns an array of objects, each containing the following properties:

  • member: member value in the sorted set
  • score: member associated score

Usage #

// Using callbacks (NodeJS or Web Browser)
kuzzle.memoryStorage.zrange('key', 0, -1, function (err, members) {
  // callback called once the action has completed
});
// Using promises (NodeJS only)
kuzzle.memoryStorage.zrangePromise('key', 0, -1)
  .then(members => {
    // resolved once the action has completed
  });

Callback response:

[
  { "member": "foo", "score": 1 },
  { "member": "bar", "score": 2 },
  { "member": "baz", "score": 3 }
]