how to get previous and next records for a specific record in rethinkdb

58 Views Asked by At

I am trying to get the surrounding records based on a given record id.

For example I have this records:

[{id: 1, name: 'a'},{id: 2, name: 'b'},{id: 3, name: 'c'},{id: 4, name: 'd'},{id: 5, name: 'e'},{id: 6, name: 'f'}]

Let's say I got the record id 3 and I wanted to get it's previous and next records, in this example I want to get record 2 and 4.

I am using rethinkdb-dash in my application. Thanks

0

There are 0 best solutions below