deleteExciseLogsOfExercise method

Future<void> deleteExciseLogsOfExercise(
  1. String exerciseName
)

Deletes all logged instances of exercise.

Implementation

Future<void> deleteExciseLogsOfExercise(String exerciseName) async {
  final usersSnapshot = await firestore.collection('users').get();

  for (final userDoc in usersSnapshot.docs) {
    final userRef = userDoc.reference;

    final logsSnapshot = await userRef
        .collection('exerciseLogs')
        .where('exerciseName', isEqualTo: exerciseName)
        .get();

    for (final logDoc in logsSnapshot.docs) {
      await logDoc.reference.delete();
    }
  }
}