couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: startkey/endkey and descending=true
Date Thu, 18 Jun 2009 01:11:24 GMT
Blair has the right idea here.

descending=true quite literally means "traverse the btree backwards"
and that is all. The side effect this has that catches a lot of people
is that "traverse the btree backwards" means you have to swap your
start and end keys because going backwards the logic is swapped. Or in
other words, "start" means "encountered first, given the current
traversal direction".

HTH,
Paul Davis

On Wed, Jun 17, 2009 at 8:04 PM, Blair Nilsson<blair.nilsson@gmail.com> wrote:
> I shouldn't drink so much coffee before posting, some of that didn't
> make too much sense.
>
> take the keys
> ["a",1]
> ["a",2]
> ["a",3]
> ["b",1]
> ["b",3]
> ["b",5]
>
> startkey=["a"]&endkey=["b"]
> will give you all of the keys starting with ["a"]
>
> Any key after ["a",3] and before ["b",1] can be used.
> {} is after any number, string or array (I think), so is very useful
> to use as part of a key describing a range.
>
> startkey=["a"]&endkey=["a",{}] should give you anything under ["a"],
> since it is the range containing going form the first to last possible
> key for anything under ["a"]
>
> What that means when you use descending=true, you will need to start
> with ["a",{}] and end with ["a"]
>
> Hopefully, this will make more sense, and that I have will remember to
> read my posts before I post them :)
>
> Sorry for the hurried post before.
>
> --- Blair
>

Mime
View raw message