diff --git a/functions/src/scripts/get-json-dump.ts b/functions/src/scripts/get-json-dump.ts new file mode 100644 index 00000000..d29b32fe --- /dev/null +++ b/functions/src/scripts/get-json-dump.ts @@ -0,0 +1,34 @@ +import * as admin from 'firebase-admin' +import * as _ from 'lodash' +import * as fs from 'fs' + +import { initAdmin } from './script-init' +initAdmin('james') + +import { Bet } from '../../../common/bet' +import { Contract } from '../../../common/contract' +import { getValues } from '../utils' +import { Comment } from '../../../common/comment' + +const firestore = admin.firestore() + +async function getJsonDump() { + console.log('Downloading contracts') + const contracts = await getValues(firestore.collection('contracts')) + console.log('Loaded contracts', contracts.length) + fs.writeFileSync('contracts.json', JSON.stringify(contracts, null, 2)) + + console.log('Downloading bets') + const bets = await getValues(firestore.collectionGroup('bets')) + console.log('Loaded bets', bets.length) + fs.writeFileSync('bets.json', JSON.stringify(bets, null, 2)) + + console.log('Downloading comments') + const comments = await getValues( + firestore.collectionGroup('comments') + ) + console.log('Loaded comments', comments.length) + fs.writeFileSync('comments.json', JSON.stringify(comments, null, 2)) +} + +if (require.main === module) getJsonDump().then(() => process.exit())