f3r:download-collection-csv

Export a collection to csv


Install
meteor add f3r:[email protected]=0.0.9

Contributors

Luis Krister Viirsaar Fer Martin Adam Brown


See all contributors


Documentation

export-csv

Meteor export mongo collection to csv

Meteor methods server side

download: function() {
  var collection = CollectionToExtract.find().fetch();
  var heading = true; // Optional, defaults to true
  var delimiter = ";" // Optional, defaults to ",";
  return exportcsv.exportToCSV(collection, heading, delimiter);
}

JavaScript file, client side

//events
'click #buttonDownload': function(event) {
  var nameFile = 'fileDownloaded.csv';
  Meteor.call('download', function(err, fileContent) {
    if(fileContent){
      var blob = new Blob([fileContent], {type: "text/plain;charset=utf-8"});
      saveAs(blob, nameFile);
    }
  });

Known issues

  • Documents need to have an identical length of elements.
  • Objects are not displayed (export JSON instead).