title: Firestore FieldValue.arrayUnion not working in a Cloud Function
body: <p>I try to use the arrayUnion functionality of Firestore to add items to an Array.
  I have a web application and the code below works fine and the elements are added to MyArray :</p>
  
  <pre><code>firebase.firestore().collection("MyCollection").doc("MyDocument").update({
       MyArray: firebase.firestore.FieldValue.arrayUnion({element1: "qqq", element2: "www"})
  });
  </code></pre>
  
  <p>But when I try to make it working in a cloud function, the code doesn't do anything. Nothing is written in my Firestore Array and there is no error on the cloud function logs.</p>
  
  <p>Initialization :</p>
  
  <pre><code>const admin = require('firebase-admin');
  admin.initializeApp();
  </code></pre>
  
  <p>My cloud function has an HTTP trigger that works fine. The code in the cloud function is :</p>
  
  <pre><code>admin.firestore().collection("MyCollection").doc("MyDocument").update({
       MyArray: admin.firestore.FieldValue.arrayUnion({element1: "qqq", element2: "www"})
  });
  </code></pre>
  
  <p>The same code with a simple element added, in the same HTTP triggered cloud function works fine :</p>
  
  <pre><code>admin.firestore().collection("MyCollection").doc("MyDocument").update({
       element1: "qqq"
  });
  </code></pre>
  
  <p>It seems that admin.firestore.FieldValue.arrayUnion doesn't do anything.</p>
  
  <p>The complete cloud function is deployed fine :</p>
  
  <pre><code>exports.test = functions.https.onRequest((req, res) =&gt; {
     admin.firestore().collection("MyCollection").doc("MyDocument").update({
  
         MyArray: admin.firestore.FieldValue.arrayUnion({element1: "qqq", element2: "www"})
  
     });
     res.status(200).end();
  });
  </code></pre>
  
  <p>He is my package.json file, all packages are up to date :</p>
  
  <pre><code>{
     "name": "functions",
     "description": "Cloud Functions for Firebase",
     "scripts": {
     "serve": "firebase serve --only functions",
     "shell": "firebase experimental:functions:shell",
     "start": "npm run shell",
     "deploy": "firebase deploy --only functions",
     "logs": "firebase functions:log"
  },
  "dependencies": {
     "@google-cloud/storage": "^1.7.0",
     "admin": "^1.4.0",
     "firebase": "^5.5.9",
     "firebase-admin": "^6.2.0",
     "firebase-functions": "^2.1.0",
     "firestore": "^1.1.6",
  },
  "private": true
  }
  </code></pre>
  
  <p>Am I missing something ? Thanks a lot !</p>