Created
April 25, 2017 12:55
-
-
Save loopiezlol/02327cf9a48a436e9bac7fa31e2bf034 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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