How to get a range of elements from an array in Redisjson?

466 views Asked by At

I have a simple array as such :

[1,2,3,4,5]

and I wish to get a range for example from index 2 to index 4. I can get the last element of the array by :

json.get key .[-1]

However I cannot find anyway to return a specific results without trimming the array.

Is there anyway I can get a range of elements from a Redis json array?

1

There are 1 answers

0
Hypothesis On BEST ANSWER

The answer is :

await Client.json.get("key" , {path : '$.[1:3]'})

which gets index 1 to 3.