Created
June 23, 2021 21:10
-
-
Save stargazing-dino/26eb96d7a8f1c13cc4c0dfe13fe00edf to your computer and use it in GitHub Desktop.
Changes the text of questions
This file contains 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
import admin = require('firebase-admin'); | |
const serviceAccount: { [key: string]: any } = require('../service_key.json'); | |
admin.initializeApp({ | |
credential: admin.credential.cert(serviceAccount), | |
databaseURL: 'https://remac-test-prep.firebaseio.com', | |
}); | |
const firestore = admin.firestore(); | |
const questionsCopyCollection = firestore.collection('questions_copy'); | |
questionsCopyCollection.get().then(async (snapshot) => { | |
const batch = admin.firestore().batch(); | |
for (const questionCopyDoc of snapshot.docs) { | |
const questionData = questionCopyDoc.data(); | |
const newQuestionText = myConversionFunction(questionData['question']); | |
batch.update( | |
questionCopyDoc.ref, | |
{ | |
...questionCopyDoc, | |
question: newQuestionText | |
} | |
); | |
} | |
await batch.commit(); | |
}).catch(console.error); | |
const myConversionFunction = (questionText: string): string => { | |
// TODO: | |
throw 'Not implemented'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment