title: loop through documents in a collection to get fields
body: <p>I have a collection called users in firebase firestore. Each document in the collection users is a user registered in the app. Each document has a field called token_ids. How can I loop through all the documents to get the values in the token_ids field. I am using firebase cloud functions to do so. Here is the code snippet I tried using but it did not work:</p>
  <pre><code>const functions = require('firebase-functions');
  const admin = require ('firebase-admin');
  admin.initializeApp();
  
    //fetch all token ids of users
  
    const tokenReference = admin.firestore().collection(&quot;users&quot;);
  
    const tokenSnapshot  = await tokenReference.get();
  
    tokenSnapshot.forEach((doc) =&gt;{
  
      console.log(&quot;Token ids are:&quot; + doc.data().token_id);
  
  
    });
  
    });
  
  </code></pre>