title: Firebase: How to update and get same document within one query?
body: <p>I am using firebase to generate receipts for my app. To generate sequential receipt number to all receipts, i am maintaining a collection which has total number of receipts.</p>
  <p>I am using firebase &quot;increment&quot; feature to increment total number of receipts by &quot;1&quot; and then again querying that document to get latest receipt number. Thus I am updating and getting same document.</p>
  <p>Is there any other cleaner way where I don't have to query twice on same document?</p>
  <p>Here is what I am doing so far:</p>
  <p>code:</p>
  <pre><code> admin
       .firestore()
       .collection(&quot;totalTransactions&quot;)
       .doc(&quot;total&quot;)
       .update({ total: admin.firestore.FieldValue.increment(1) })
       .then(() =&gt; {
           admin
               .firestore()
               .collection(&quot;totalTransactions&quot;)
               .doc(&quot;total&quot;)
               .get()
               .then((totalTxn) =&gt; {
                   const receiptNo = totalTxn.data().total;
               })
          })
  
  </code></pre>