title: Firestore Add value to array field
body: <p>Im trying to use Firebase cloud functions to add the id of a chatroom to the users document in an array field. I cant seem to figure out the way to write to an array field type. here is my cloud function</p>
  
  <pre><code>  exports.updateMessages = functions.firestore.document('messages/{messageId}/conversation/{msgkey}').onCreate( (event) =&gt; {
      console.log('function started');
      const messagePayload = event.data.data();
      const userA = messagePayload.userA;
      const userB = messagePayload.userB;   
  
          return admin.firestore().doc(`users/${userA}/chats`).add({ event.params.messageId }).then( () =&gt; {
  
          });
  
    });
  </code></pre>
  
  <p>here is the way my database looks</p>
  
  <p><a href="https://i.stack.imgur.com/vxqKD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vxqKD.png" alt="enter image description here"></a></p>
  
  <p>any tips greatly appreciated, Im new to firestore.</p>