CSV Export via CouchDB list function
Sometimes you need to get a data from your CouchDB in CSV format for some thrid-party application, or someone from your office need to write another report in Excel, etc, so here is the tiny pice of code that can give you a hint on how to create a list function that will export your data into CSV:
function (head, req) {
start({"headers": {
"Content-Type": "text/csv"
}
});
send('Username, Name, Email\n');
while(row = getRow()) {
send(row.value.username+','+row.value.email+','+row.value.metadata.name+'\n');
}
}