title: Accessing a collection inside of a document in firestore
body: <p>I have a document, and inside of it there is a collection called <code>relatives</code>. In cloud functions, I have <code>onUpdate()</code> listener for this document. Once something is changed, I want to access that collection inside of my document. Also documents in the collection <code>relatives</code>.</p>
  <p>Here is how it looks like:</p>
  <p><a href="https://i.stack.imgur.com/eHv8U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eHv8U.png" alt="enter image description here" /></a></p>
  <hr />
  <h3>What I have tried</h3>
  <pre class="lang-js prettyprint-override"><code>exports.UpdateLocations = functions.firestore.document(&quot;users/{userID}&quot;).onUpdate((change, context) =&gt; {
      const userEmail = change.after.data().email;
      const prevLocation = change.before.data().userLocation;
      const currentLocation = change.after.data().userLocation;
  
      if (prevLocation === currentLocation) return 0;
  
      if (change.after.data().userType.toString() === &quot;Patient&quot;) {
          const userLocation = change.after.data().userLocation;
          const relatives = change.after.data().relatives;
  
          console.log(&quot;User's Current Location: &quot; + userLocation);
          console.log(&quot;Relatives : &quot;+relatives );
  
      }
      return;
  
  });
  
  </code></pre>
  <hr />
  <p>I want to access relatives and its documents. So I can search and compare field and update them on purpose.</p>