tarantool

How do I select a range of keys from tarantool, like with SELECT BETWEEN in SQL?


Since this is on of the most common questions in https://t.me/tarantool and https://t.me/tarantoolru, I post the answer here.


Solution

  • space:pairs(from, 'GE'):
       take_while(function(x) return x.field <= to end)
       -- :totable() or use the result in the for-loop
    

    For multipart keys see https://stackoverflow.com/a/57766656/1135874