Skip to content

Instantly share code, notes, and snippets.

@evilUrge
Last active May 2, 2019 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evilUrge/2905b5fdf8eb3a82dd6eaa6fb46e714e to your computer and use it in GitHub Desktop.
Save evilUrge/2905b5fdf8eb3a82dd6eaa6fb46e714e to your computer and use it in GitHub Desktop.
Fetch configurations from Firestore's collection "configurations" as json files.
process.env.NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
require('../src/firebase').admin.firestore().collection('configurations').get()
.then(documents =>
documents.forEach((document) =>
require('fs').writeFile(`${require('../src/utils').baseDir}/config/${document.id}.json`, JSON.stringify(document.data()), (error) =>
error ? console.error(error) : console.log(`Configuration file ${document.id}.json has been created!`))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment