async function resetData()

in codelab-initial-state/functions/test.js [238:253]


async function resetData(db, projectId) {
  await firebase.withFunctionTriggersDisabled(async () => {
    // Get the items collection before we delete everything
    const items = await db.collection('items').get();

    // Clear all data
    await firebase.clearFirestoreData({
      projectId
    });

    // Restore the items collection
    for (const doc of items.docs) {
      await doc.ref.set(doc.data());
    }
  });
}