Skip to content

Instantly share code, notes, and snippets.

@boxxxie
Created June 24, 2012 20:43
Show Gist options
  • Save boxxxie/2984830 to your computer and use it in GitHub Desktop.
Save boxxxie/2984830 to your computer and use it in GitHub Desktop.
example of using csv show on couchdb
_export_csv:function(convert_to_array,file_name){
var export_db = 'export_requests_rt7';
var router = this;
var handler = {
success:function(resp){
var href = window.location.origin + '/'+ export_db +'/_design/app/_show/csv/' + resp.id;
window.location.href = href;
},
error:function(){
alert('there was an error exporting your data');
}
};
if(_.isUndefined(router.current_view_data)){
alert("there is no data to save");
return undefined;
}
var doc = {
_id:$.couch.newUUID(),
file_name:file_name,
file_ext:'csv',
date:(new Date()).toJSON(),
content:convert_to_array(router.current_view_data)
};
$.couch.db(export_db).saveDoc(doc,handler);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment