title: How to delete a Firestore field inside a map that is an array element?
body: <p>I would like to be able to delete <code>varToDelete</code> field inside a map if a condition occurs.</p>
  <p>For some reason, the code to delete it is reached, but nothing is happening</p>
  <p>Here is the structure of my document:</p>
  <pre><code>loc [
    {
      var1,
      var2,
      varToDelete
    },
    {
      var1,
      var2,
      varToDelete
    }
  ]
  </code></pre>
  <p>So, I started to think about this code:</p>
  <pre><code>await db.runTransaction(async (t) =&gt; {
  
    var locRef = db.collection('documents').doc('123-456');
    var locSnapshot = await locRef.get();
    var loc = locSnapshot.data().loc;
  
    loc.forEach(l =&gt; {
      if (typeof l.varToDelete !== 'undefined') {
        t.update(locRef, {
          &quot;varToDelete&quot;: admin.firestore.FieldValue.delete()
        });
      }
    });
  });
  </code></pre>