forked from fireship-io/fireship-quizapp-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquizzes.js
49 lines (35 loc) · 900 Bytes
/
quizzes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const admin = require('firebase-admin');
const fs = require('fs-extra');
const yaml = require('yamljs');
admin.initializeApp({
credential: admin.credential.cert(require('./credentials.json')),
});
const db = admin.firestore();
const quizzes = [
'angular-basics',
'flutter-scroll',
'cf-basics',
'cf-triggers',
'firebase-perf',
'firestore-basics',
'flutter-basics',
'flutter-containers',
'flutter-flex',
'flutter-gestures',
'flutter-material',
'flutter-scroll',
'js-basics',
'js-variables',
'rxjs-basics',
'ts-basics'
]
const update = async(quizId) => {
const json = yaml.load(`quizzes/${quizId}.yaml`);
console.log(JSON.stringify(json));
const ref = db.collection('quizzes').doc(quizId);
await ref.set(json, { merge: true });
console.log('DONE');
}
for (const quiz of quizzes) {
update(quiz);
}