title: How to update an "array of objects" with Firestore?
body: <p>I'm currently trying Firestore, and I'm stuck at something very simple: "updating an array (aka a subdocument)".</p>
  
  <p>My DB structure is super simple. For example:</p>
  
  <pre><code>proprietary: "John Doe",
  sharedWith:
    [
      {who: "first@test.com", when:timestamp},
      {who: "another@test.com", when:timestamp},
    ],
  </code></pre>
  
  <p>I'm trying (without success) to push new records into <code>shareWith</code> array of objects.</p>
  
  <p>I've tried:</p>
  
  <pre><code>// With SET
  firebase.firestore()
  .collection('proprietary')
  .doc(docID)
  .set(
    { sharedWith: [{ who: "third@test.com", when: new Date() }] },
    { merge: true }
  )
  
  // With UPDATE
  firebase.firestore()
  .collection('proprietary')
  .doc(docID)
  .update({ sharedWith: [{ who: "third@test.com", when: new Date() }] })
  </code></pre>
  
  <p>None works. These queries overwrite my array.</p>
  
  <p>The answer might be simple, but I could'nt find it...</p>