Skip to content

Instantly share code, notes, and snippets.

@eiri
Created April 28, 2018 03:17
Show Gist options
  • Save eiri/a61cdda91261648c04d83a109664bb94 to your computer and use it in GitHub Desktop.
Save eiri/a61cdda91261648c04d83a109664bb94 to your computer and use it in GitHub Desktop.
How Couch query parameters work

How Couch query parameters work

This is a table showing a relationship between CouchDB view and _all_docs query parameters start_key, end_key, descending and inclusive_end. Obvious things to notice: 1) Start key always included 2) inclusive_end doesn't affect starting key 3) from A to B asc not equal from B to A desc.

 start_key | end_key | inclusive_end | descending |
                                                    [ 1 | 2 | 3 | 4 | 5 | 6 ]
 null      | null    | true          | false      |   1 ----------------> 6
 null      | null    | true          | true       |   1 <---------------- 6
 3         | null    | true/false    | false      |           3 --------> 6
 3         | null    | true/false    | true       |   1 <---- 3
 null      | 3       | true          | false      |   1 ----> 3
 null      | 3       | true          | true       |           3 <-------- 6
 null      | 3       | false         | false      |   1 > 2
 null      | 3       | false         | true       |               4 <---- 6
 3         | 5       | true          | false      |           3 ----> 5
 3         | 5       | true          | true       |          -/-
 5         | 3       | true          | false      |          -/-
 5         | 3       | true          | true       |           3 <---- 5
 3         | 5       | false         | false      |           3 > 4
 3         | 5       | false         | true       |          -/-
 5         | 3       | false         | false      |          -/-
 5         | 3       | false         | true       |               4 < 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment