Skip to content

Instantly share code, notes, and snippets.

@davidbanham
Last active December 15, 2015 04:50
Show Gist options
  • Save davidbanham/5204449 to your computer and use it in GitHub Desktop.
Save davidbanham/5204449 to your computer and use it in GitHub Desktop.
Example of couchdb array keys
// Design Doc:
{
"_id": "_design/things",
"_rev": "3-c05af422e754a6734d1843e309fa1135",
"language": "javascript",
"views": {
"filter": {
"map": "function(doc) { emit([doc.country, doc.city], doc); }"
}
}
}
// Queries:
// All items in country Australia, any city
http://localhost:5984/spark/_design/things/_view/filter?startkey=["Australia"]&endkey=["Australia",{}]
// All items in Sydney, Australia
http://localhost:5984/spark/_design/things/_view/filter?key=["Australia","Sydney"]
// Sample Data
{
"_id": "ee130765818e5f48dbd9544d5f0001ee",
"_rev": "1-47464d00c676152bc59aa3eac98359f8",
"country": "Australia",
"city": "Sydney"
}
{
"_id": "ee130765818e5f48dbd9544d5f000e58",
"_rev": "1-27c813768caeef789773232d2e3aa480",
"country": "Australia",
"city": "Brisbane"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment