title: TypeError: elements.get is not a function error in firebase functions
body: <p>I am getting the below <code>error log</code> when running a firebase function, i am trying to get documents and values inside <code>recentPosts</code> array field.</p>
  
  <pre><code>Error: Unknown error status: Error: Unknown error status: TypeError: elements.get is not a function
      at new HttpsError (/srv/node_modules/firebase-functions/lib/providers/https.js:90:19)
      at admin.firestore.collectionGroup.where.get.then.catch.error (/srv/lib/index.js:71:15)
      at &lt;anonymous&gt;
      at process._tickDomainCallback (internal/process/next_tick.js:229:7)
  </code></pre>
  
  <p><strong><em>Class:</em></strong></p>
  
  <pre><code>class PostTable {
     public commentCount : number;
  
     public dateTime : number;
  
     public docId : string;
  
     public post : string;
  
     public userId : string;
  
     public userName : string;
  
     constructor(commentCount: number, dateTime: admin.firestore.Timestamp, docId: string, post : string, userId : string, userName : string) {
  
         this.commentCount = commentCount
         this.dateTime=  dateTime.toDate().getTime()
         this.docId=docId
         this.post=post
         this.userId=userId
         this.userName=userName
     }
  
  }
  </code></pre>
  
  <p><strong><em>function:</em></strong></p>
  
  <pre><code>export const getPosts = functions.https.onCall((data, context) =&gt; {
  
     if (!context.auth) {
        // Throwing an HttpsError so that the client gets the error details.
        throw new functions.https.HttpsError('failed-precondition', 'The function must be called ' +
            'while authenticated.');
      }
  
  
      let responseCollection : PostTable[] = []
  
           admin.firestore().collectionGroup('recentPostColl').where('users', "array-contains",context.auth.token.name)
                                   .get()
  
           .then(collectionOfPosts =&gt; {
  
              if(!collectionOfPosts.empty)
              {
  
                 collectionOfPosts.forEach(element =&gt; {
  
                    let collection : Map&lt;String, Object&gt;[] = element.get('recentPosts')
  
                    collection.forEach(elements =&gt; {
  
                       try {
                          const p : PostTable = new PostTable(elements.get('commentCount')as number, elements.get('dateTime') as admin.firestore.Timestamp
                          ,elements.get('docId') as string,elements.get('post') as string, elements.get('userId') as string, elements.get('userName') as string);
  
                          const stamp : admin.firestore.Timestamp = elements.get('dateTime') as admin.firestore.Timestamp
  
                          const date : Date = stamp.toDate()
  
                          if(date.getTime() &gt; new Date(data.date).getTime())
                          {
  
                                responseCollection.push(p)
                          }
                       } catch (error) {
                          throw new functions.https.HttpsError(error, 'Constructor error');
                       }
  
                    });
                 });
  
              }
  
  
     })
  
     .catch(error =&gt;{
        throw new functions.https.HttpsError(error, 'code error');
     })
  
     return responseCollection
  
  
  })
  </code></pre>
  
  <p><strong><em>Document:</em></strong></p>
  
  <p><a href="https://i.stack.imgur.com/ft9iO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ft9iO.png" alt="enter image description here"></a></p>