Struggling to define views
in a readable way because they are set in JSON
in CouchDB
.
Consider this example:
{
"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); } } }"
}
}
}
Having the map function as a long string makes it difficult to read and debug. What is the best approach to defining views in CouchDB
? It seems like I'm missing something obvious.