title: How to store maps to a firestore array
body: <p>I have xyz document inside abc collection.</p>
  <ul>
  <li>I want to add a <strong>map</strong> to <strong>an array</strong> inside <strong>document xyz</strong>.</li>
  </ul>
  <p>I can add a single array item using this code</p>
  <pre><code>CollectionReference collection = this.collection(collection);
  DocumentReference ref = collection.document(document);
  ref.setData({&quot;data&quot;: FieldValue.arrayUnion(values)});
  </code></pre>
  <p>here <strong>data</strong> is the parent array.</p>
  <p>but when I try to add another <strong>map</strong> , firestore <strong>replace the values</strong> of index <strong>0</strong> , it <strong>does not add map to next index</strong>  means to index 1,2,3 or .....</p>
  <p>let see the example
  here is the map</p>
  <pre><code>    values = {
          &quot;tokens&quot;: &quot;99&quot;,
          &quot;title&quot;: &quot;Cleaning&quot;,
          &quot;location&quot;: {&quot;  lat&quot;: &quot;34.4333&quot;, &quot;lng&quot;: &quot;53.4343&quot;},
          &quot;id&quot;: &quot;gVnGE5ZPRnQ8HYQq7dvT&quot;,
          &quot;client&quot;: &quot;LFBXXj7Zi0xOr0FqBGID&quot;,
          &quot;date&quot;: &quot;22/8/2019&quot;,
          &quot;message&quot;: &quot;request message...&quot;,
          &quot;budget&quot;: &quot;150&quot;,
          &quot;details&quot;: {
          &quot;  When would you like to have the cleaners over?&quot;:
              &quot;week&quot;,
          &quot;What type of cleaning package would you prefer?&quot;:
              &quot;answer for the type of clean&quot;,
          &quot;Do you need the cleaning tools and materials?&quot;:
              &quot;false&quot;,
          &quot;What time do you prefer to have the cleaners over?&quot;:
              &quot;8/20/2019&quot;
          }
      }
  </code></pre>
  <p>and I want to add it as new array item each time when I send data to the firestore</p>
  <p>eg.</p>
  <pre><code>    onTap() {
          CollectionReference collection = this.collection(collection);
          DocumentReference ref = collection.document(document);
          ref.setData({&quot;value&quot;: FieldValue.arrayUnion(values)});
      }
  </code></pre>
  <hr />
  <p>here is the code</p>
  <pre><code>    var values = {
          &quot;tokens&quot;: &quot;99&quot;,
          &quot;title&quot;: &quot;Cleaning&quot;,
          &quot;location&quot;: {&quot;  lat&quot;: &quot;34.4333&quot;, &quot;lng&quot;: &quot;53.4343&quot;},
          &quot;id&quot;: &quot;gVnGE5ZPRnQ8HYQq7dvT&quot;,
          &quot;client&quot;: &quot;LFBXXj7Zi0xOr0FqBGID&quot;,
          &quot;date&quot;: &quot;22/8/2019&quot;,
          &quot;message&quot;: &quot;request message...&quot;,
          &quot;budget&quot;: &quot;150&quot;,
          &quot;details&quot;: {
          &quot;  When would you like to have the cleaners over?&quot;:
              &quot;week&quot;,
          &quot;What type of cleaning package would you prefer?&quot;:
              &quot;answer for the type of clean&quot;,
          &quot;Do you need the cleaning tools and materials?&quot;:
              &quot;false&quot;,
          &quot;What time do you prefer to have the cleaners over?&quot;:
              &quot;8/20/2019&quot;
          }
      }
  
      onTap() {
          CollectionReference collection = this.collection(collection);
          DocumentReference ref = collection.document(document);
          ref.setData({&quot;value&quot;: FieldValue.arrayUnion(values)});
      }
  </code></pre>