title: Using firebase .update within a .where (instead of .doc)
body: <p>I am new to firebase and am struggling a little bit. </p>
  
  <p>Currently, I am trying to update an array within a user, within a document. However, I cannot match the user to current user using the unique ID, as each users unique ID is their username, and it may have changed since creation.</p>
  
  <p>I figured the best way to match the documents user to the current user would be to use a .where().get() and then use an "update()" to update the array.</p>
  
  <p>Now, this is where I am getting stuck. In the firebase documents, their <a href="https://stackoverflow.com/questions/ask">example</a> of using .update is attached to a .doc </p>
  
  <pre><code>var washingtonRef = db.collection("cities").doc("DC");
  
  //Atomically add a new region to the "regions" array field.
  washingtonRef.update({
    regions: firebase.firestore.FieldValue.arrayUnion("greater_virginia")
  });
  </code></pre>
  
  <p>However, as I am using a .where, I assume I have to use references and snapshots. But, I am not quite sure how references work in this scenario and, with that, how to update properly. </p>
  
  <p>Here is the code I have after a while of messing round, but no matter my variations i cannot figure it out. (essentially, I want to add a new project (in this case called "new project" to the users array of postedProjects.)</p>
  
  <pre><code> db.collection('users').where('user_id', '==', this.userInfo.user_id)
    .get()
    .then(function(querySnapshot)  {
      querySnapshot.forEach(function(doc) {
  
      doc.data().update({
        postedProjects: firebase.firestore.FieldValue.arrayUnion("new project")
      })
    })
  })
  </code></pre>
  
  <p>This gives me an error of ".update() is not a function". </p>
  
  <p>Is anyone able to help me with my solution to show me <em>how</em> references should properly be used in this scenario?</p>