Since views
are defined with JSON
in CouchDB
I'm having a hard time defining those in a human readable fashion.
Take this document:
{
"language": "javascript",
"views": {
"by_location": {
"map": "function(doc) { if (doc.location != null) emit(doc.location, doc) }"
},
"by_location_tags": {
"map": "function(doc) { if (doc.top_tags) { for(i=0;i<doc.top_tags.length;i++) { emit([doc.top_tags[i].tag_name, doc.location], doc); } } }"
}
}
}
Writing the map function as one long string is plain ugly and it's insanely hard to spot bugs. I wonder what is the workflow for defining views in CouchDB
? I feel as I'm missing the obvious.
In addition to mentioned Futon, there are several tools that allow you to write your map and view functions with your favorite editors and save them on your local file system. Those tools than take care of "pushing" your code to CouchDB.
You can find more about those tools here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With