title: Currently refactoring my Firestore post data function into an array storage
body: <p>Currently I have a dashboard application and when a user adds to their dashboard it does a post request to Firestore to set the data in a certain document. Here is what that code looks like:</p>
  <pre><code>export function createEntry(data) { // Data has a authorId key with the value of the UID
    const userEntry = firestore.collection('userEntries').doc();
    userEntry.set(data);
    return userEntry;
  }
  </code></pre>
  <p>So above, a new entry gets created with a random ID that I  then use to grab the data to display later. To get this information later, I loop through all of the entries to see where the authorId matches the user that is log in to return that.</p>
  <p>So what I am trying to do is refactor the code so that each document in 'userEntries' is the ID of the user, authorID: UID, and have it be an array where I can keep pushing items into. In return, I can just grab the user array and map over those items to display instead of looping through all my entries and checking.</p>
  <p>What I've tried:</p>
  <pre><code>export function createEntry(data) {
    const userEntry = firestore.collection('userEntries').doc(data.authorId);
    userEntry.update({ 
      userData: firebase.firestore.FieldValue.arrayUnion(data)
    })
  }
  </code></pre>
  <p>So to sum it up, I would like a way to set the document to users ID and push any future entries into their own array, in which I could easily access from the frontend to display.</p>
  <p>Hope you can point me in the right direction, thank you!</p>