title: Can Firestore update multiple documents matching a condition, using one query?
body: <p>In other words, I'm trying to figure out what is the Firestore equivalent to this in SQL:</p>
  
  <pre><code>UPDATE table SET field = 'foo' WHERE &lt;condition&gt;`
  </code></pre>
  
  <p>Yes, I am asking how to <a href="https://stackoverflow.com/questions/46618601/how-to-create-update-multiple-documents-at-once-in-firestore">update multiple documents</a>, <a href="https://stackoverflow.com/questions/46848801/how-to-do-a-bulk-update-in-firestore">at once</a>, but unlike the linked questions, I'm specifically asking how to do this in one shot, <em>without reading anything into memory</em>, because there's no need to do so when all you want is to set a flag on all documents matching a condition.</p>
  
  <pre><code>db.collection('table')
    .where(...condition...)
    .update({
      field: 'foo',
    });
  </code></pre>
  
  <p>is what I expected to work, <a href="https://cloud.google.com/nodejs/docs/reference/firestore/0.11.x/CollectionReference" rel="noreferrer">CollectionReference</a> doesn't have an <code>.update</code> method.</p>
  
  <p>The <a href="https://firebase.google.com/docs/firestore/manage-data/transactions" rel="noreferrer">
  Transactions and Batched Writes</a> documentation mentions transactions and batched writes. Transactions are out because "A transaction consists of any number of <strong>get() operations</strong> followed by any number of write operations" <a href="https://firebase.google.com/docs/firestore/manage-data/transactions#batched-writes" rel="noreferrer">Batched writes</a> are also not a solution because they work document-by-document.</p>
  
  <p>With <a href="https://docs.mongodb.com/manual/reference/method/db.collection.update/#example-update-specific-fields" rel="noreferrer">MongoDB</a>, this would be</p>
  
  <pre><code>db.table.update(
    { /* where clause */ },
    { $set: { field: 'foo' } }
  )
  </code></pre>
  
  <p>So, can Firestore update multiple documents with one query, the way SQL database or MongoDB work, i.e. without requiring a round-trip to the client for each document? If not, how can this be done efficiently?</p>