title: get the number of documents before and after Firestore trigger - Cloud functions
body: <p>I'm trying to get the number of documents in a collection before and after a document has been added using <code>cloud functions</code>, the code in nodeJs I wrote is this:</p>
  <pre><code>exports.onShowcaseCreated = functions.firestore
  .document(&quot;Show/{document}&quot;)
  .onCreate((snapshot, context) =&gt; {
    const showcaseDict = snapshot.data();
    const uid = showcaseDict.uid;
    return db.collection(&quot;Showcases&quot;).where(&quot;uid&quot;, &quot;==&quot;, uid).get()
        .then((showsnap) =&gt; {
            const numberOfShowcaseBefore = showsnap.size.before;
            const numberOfShowcaseAfter = showsnap.size.after;
            console.log( numberOfShowcaseBefore, numberOfShowcaseAfter);
            if ( numberOfShowcaseBefore == 0 &amp;&amp; numberOfShowcaseAfter == 1 ) {
              return db.collection(&quot;Users&quot;).doc(uid).update({
                timestamp: admin.firestore.Timestamp.now(),
              });
          });
        });
  });
  </code></pre>
  <p>but the console logs are <code>undefined undefined</code> it seems like this is not the right approach for taking the number of documents before and after a document has beed added</p>