Compound Key Comparition


#1

Hi all,
I have a problem when trying to select using compound key.
This is my data forexample
{ id : 1 , start : 1434093315000 , end : 1434095315000 }

My inputs are startDate and endDate
Now I would like to select all data that has the startDate < start < end < endDate.
How can I do that ?

Thanks,
Dong


#2

let me reformulate: you want all docs

  • of id X (a constant)
  • that match start > a (a date variable, startDate)
  • and end < b (a date variable, endDate)?

Provided your view emits compound keys of [ id, start, end ], what about the following query parameters?

startKey = [ X, a, MINVALUE ]
endKey = [ X, MAXVALUE, b ]

where MINVALUE is a relevant lower bound (for instance 0, or the EPOCH timestamp, or anything long ago enough in time for timestamps), and MAXVALUE is a relevant upper bound (for example query time in timestamp form)