Skip to content

Instantly share code, notes, and snippets.

@evilUrge
Last active May 2, 2019
Embed
What would you like to do?
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