Relative Content

Tag Archive for node.jsgoogle-cloud-firestore

Firestore cycle for and update function are not in sync

I’m new to firestore cloud functions. I’m trying to write a function that based on the change of one collection should be updated the data of another collection. I create cycle for on the ingredients, the update function works, but it assign the last value of the for cycle to the “total_amount” and “partial_amount”. I.e. I have the ingredient “Zucchini” with 20 as amount and “Tomato” with 50 as amount and the update function assign 50 to both the document in aggregate_ingrdients collection instead the corresponding one. Seems the cycle for and the update function are not in sync. Could be an issue of async function? How can I solve it?