diff --git a/functions/index.js b/functions/index.js index 6e6b310..5942d4d 100644 --- a/functions/index.js +++ b/functions/index.js @@ -239,6 +239,8 @@ exports.createProgress = functions.https.onCall((data, context) => { } shuffleArray(allVocab).forEach((doc, index, array) => { + let batch = db.batch(); + const vocabId = doc.vocabId; const terms = { @@ -252,6 +254,16 @@ exports.createProgress = functions.https.onCall((data, context) => { dataToSet.questions.push(vocabId); + if (index > 248) { + batch.set( + progressDocId.collection("terms").doc(vocabId), + terms + ); + batch.set( + progressDocId.collection("definitions").doc(vocabId), + definitions + ); + } else { transaction.set( progressDocId.collection("terms").doc(vocabId), terms