Created
January 18, 2011 07:09
-
-
Save nilakanta/784077 to your computer and use it in GitHub Desktop.
couch view with include_docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create Documents and view | |
========================= | |
curl -X PUT http://localhost:5984/testdb -d {} | |
curl -X PUT http://localhost:5984/testdb/Claire -d '{"title": "VP of Official Attitude"}' | |
curl -X PUT http://localhost:5984/testdb/Mikeal -d '{"title": "VP of Pastries and Automating Stuff"}' | |
curl -X PUT http://localhost:5984/testdb/Jason -d '{"title": "VP of Hosting and Lightning"}' | |
curl -X PUT http://localhost:5984/testdb/team -d '{"members": ["Claire", "Mikeal", "Jason"]}' | |
curl -X PUT http://localhost:5984/testdb/_design/myview -d '{"language":"javascript","views":{"test":{"map":"function(doc) {if(doc.members) {doc.members.forEach(function(member) {emit(member, {_id: member});});}}"}}}' | |
Test the view | |
============= | |
curl -X GET http://localhost:5984/testdb/_design/myview/_view/test | |
>>{"total_rows":3,"offset":0, | |
"rows":[ | |
{"id":"team","key":"Claire","value":{"_id":"Claire"}}, | |
{"id":"team","key":"Jason","value":{"_id":"Jason"}}, | |
{"id":"team","key":"Mikeal","value":{"_id":"Mikeal"}} | |
] | |
} | |
curl -X GET http://localhost:5984/testdb/_design/myview/_view/test?include_docs=true | |
>>{"total_rows":3,"offset":0, | |
"rows":[ | |
{"id":"team","key":"Claire","value":{"_id":"Claire"},"doc":{"_id":"Claire","_rev":"1-793f4bbbbfe3f2f9154d6e53f260c026","title":"VP of Official Attitude"}}, | |
{"id":"team","key":"Jason","value":{"_id":"Jason"},"doc":{"_id":"Jason","_rev":"1-8b263255e0676ea3000455a0614d3cdd","title":"VP of Hosting and Lightning"}}, | |
{"id":"team","key":"Mikeal","value":{"_id":"Mikeal"},"doc":{"_id":"Mikeal","_rev":"1-08ec6690a9da3a93431c5d82c7518595","title":"VP of Pastries and Automating Stuff"}} | |
] | |
} | |
curl -X DELETE http://localhost:5984/testdb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment