I have a yoga app where users complete exercises and press a “complete” button to add the exercise to an array of maps within a Firestore document. Each exercise has a different duration (time) and calorie burn (kcal).
I want to calculate the total time and total kcal each time a new exercise is added to this array. My Firestore structure includes a document for each date. If today’s date matches an existing document, I add the completed exercise to that document. If not, I create a new document for the current date and add the exercise to it.
How can I calculate the total_time and total_kcal when a new exercise is added to the array in Firestore?
[[enter image description here](https://i.sstatic.net/6hT84CBM.png)](https://i.sstatic.neenter image description heret/WxGQNnZw.png)
Vaibhav Tiwari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.