Skip to content

Instantly share code, notes, and snippets.

@loopiezlol
Created April 25, 2017 12:55
Show Gist options
  • Select an option

  • Save loopiezlol/02327cf9a48a436e9bac7fa31e2bf034 to your computer and use it in GitHub Desktop.

Select an option

Save loopiezlol/02327cf9a48a436e9bac7fa31e2bf034 to your computer and use it in GitHub Desktop.
const co = require('co');
const json2xls = require('json2xls');
module.exports = function() {
co(function*() {
const Insight = require('../../app/models/insight');
const fs = require('fs');
const games = yield Insight.find({
type: { $ne: 'normal' },
status: 'approved',
}, {
content: 1,
headline: 1,
}).lean();
console.log('found ', games.length, ' games');
const formattedGames = games.map(g => { return {
title: g.headline,
explanation: g.content,
}});
const xls = json2xls(formattedGames);
fs.writeFileSync('data.xlsx', xls, 'binary');
console.log('done');
process.exit(0);
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment