Is there a simple way to create a text file in Meteor on the server side and download it as a .txt file?
// Server Side
if (Meteor.isServer) {
Meteor.methods({
'scan-db': function () {
// Scanning the database for corrupted data
var allEntries = Jobs.find().fetch();
var report = "";
for ( let i = 0; i < allEntries.length ; i ++ ) {
if ( validate(allEntries[i]) == false ) {
report = report + allEntries[i].entryNumber + " has a problem" + "\n";
// Using \n for line breaks in windows
}
return report; // A long string containing the report
})
}
// Client Side
if (Meteor.isClient) {
Meteor.call("scan-db", function(err, res) {
if (res) {
downloadFile(res);
}
})
}
I would like to be able to save my result as a text file. Is there an easy method to achieve this? I attempted to use meteorhacks:picker
, but it seems that the package is not functioning properly or Picker
returned undefined
even after importing it using
import { Picker } from 'meteor/meteorhacks:picker';