title: Firebase cloud function firestore array union
body: <p>I'm unable to get the array union or increment to work properly in firebase cloud functions. </p>
  
  <pre><code>return docRef.update({
  
    object: {
      count: admin.firestore.FieldValue.increment(1),
      list: admin.firestore.FieldValue.arrayUnion({
        space_id: newData.date_id,
        user: {
          displayName: "john doe"
        }
      })
    }
  </code></pre>
  
  <p>When the function runs, it simply overwrites the existing data in the list array and the count is always set to 1 even though it currently exists and is of number type.</p>