SHOW:
|
|
- or go back to the newest paste.
1 | $ curl localhost:5984 | |
2 | {"couchdb":"Welcome","uuid":"9e5ef59f41dc168d7976fda38a1b7198","version":"1.5.0","vendor":{"version":"1.5.0-1","name":"Homebrew"}} | |
3 | ||
4 | $ curl -X PUT http://localhost:5984/testdb | |
5 | {"ok":true} | |
6 | ||
7 | $ curl -X POST http://localhost:5984/testdb/_bulk_docs -H 'content-type:application/json' -d '{"docs":[{"_id":"1","key":"a"},{"_id":"2","key":"b"},{"_id":"3","key":"b"},{"_id":"4","key":"b"},{"_id":"5","key":"c"},{"_id":"6","key":"d"},{"_id":"7","key":"d"}]}' | |
8 | [{"ok":true,"id":"1","rev":"1-f443804e079279645227a179f7e373cf"},{"ok":true,"id":"2","rev":"1-d35680189514ccd6046f23daa89b0f84"},{"ok":true,"id":"3","rev":"1-d35680189514ccd6046f23daa89b0f84"},{"ok":true,"id":"4","rev":"1-d35680189514ccd6046f23daa89b0f84"},{"ok":true,"id":"5","rev":"1-081b779480759004290d1aeb5d8fa35b"},{"ok":true,"id":"6","rev":"1-ad4fdc41af538992ae8075ed3c5d5cbd"},{"ok":true,"id":"7","rev":"1-ad4fdc41af538992ae8075ed3c5d5cbd"}] | |
9 | ||
10 | $ curl -X PUT http://localhost:5984/testdb/_design/view -H 'content-type:application/json' -d '{"views" : {"view": {"map":"function (doc){emit(doc.key);}"}}}' | |
11 | {"ok":true,"id":"_design/view","rev":"1-849accd6d0a515c9f772806b6ecc1d25"} | |
12 | ||
13 | # expected 2, returns 0 | |
14 | # curl 'http://localhost:5984/testdb/_design/view/_view/view?startkey="b"&startkey_docid="2"&endkey="b"&endkey_docid="3"' | |
15 | {"total_rows":7,"offset":1,"rows":[ | |
16 | ||
17 | ]} | |
18 | ||
19 | # descending works the same way | |
20 | $ curl 'http://localhost:5984/testdb/_design/view/_view/view?startkey="b"&startkey_docid="3"&endkey="b"&endkey_docid="2"&descending=true' | |
21 | {"total_rows":7,"offset":6,"rows":[ | |
22 | ||
23 | ]} | |
24 | ||
25 | # full curl for clarity | |
26 | $ curl 'http://localhost:5984/testdb/_design/view/_view/view' | |
27 | {"total_rows":7,"offset":0,"rows":[ | |
28 | {"id":"1","key":"a","value":null}, | |
29 | {"id":"2","key":"b","value":null}, | |
30 | {"id":"3","key":"b","value":null}, | |
31 | {"id":"4","key":"b","value":null}, | |
32 | {"id":"5","key":"c","value":null}, | |
33 | {"id":"6","key":"d","value":null}, | |
34 | {"id":"7","key":"d","value":null} | |
35 | ]} |