title: Cloud Functions Scheduler Function operation
body: <p>I want to have some data extracted and written somewhere in Cloud Firestore so I wrote a scheduler function which is running fine up to now but it is not doing much.</p>
  <p>For my next step I would like to understand if when this function runs, does it get ALL the documents in ALL the collections at once? Or does it iterate through the collections one by one? The reason I need to know is because I want to create some variables and reset them when the collection changes.</p>
  <p>My current way of proceeding is this:</p>
  <pre><code>exports.schFun = rf.pubsub.schedule('0 6 * * *')
      .timeZone('Europe/London') // Users can choose timezone
      .onRun(async (context) =&gt; {
        // Should these be declared here?
        let totalNumAccepted = 0;
        let totalRevenueAccepted = 0.0;
        let totalNumRejected = 0;
        let totalRevenueRejected = 0.0;
  
        let postcode = [];
        let timeOrderPlaced = new Date();
  
        const querySnapshot = await db.collectionGroup(&quot;open_orders&quot;) // This is separate for each store
        .where('complete', '==', true)
        .get();
        querySnapshot.forEach((doc) =&gt; { 
        // Here onwards I want to fill the above variables with data fields in documents and reset the variables when &quot;open_orders&quot; collection changes...
  </code></pre>