title: Is there a way to select only certain fields from Firestore?
body: <p>I am working on a performance issue of a function, that takes 15sec to response, which makes a request to firebase for all documents that are
  <code>&quot;ErrorID&quot; &quot;==&quot; &quot;0&quot;</code>
  The problem is that there are many documents and they are kind of very large objects, and I only need <strong>TWO FIELDS</strong> <code>(Order and Amount)</code> of each document, there are any way to request only those two fields that accomplish the condition?</p>
  <p>Something like :</p>
  <pre><code>firestore.collection(&quot;purchases&quot;).where(&quot;ErrorID&quot;, &quot;==&quot;, &quot;0&quot;).get(Order, Amount); 
  </code></pre>
  <p>The function that im talking about:</p>
  <pre><code>const totalEarn = async (req, res, next) =&gt; {
    const DAY = 86400000;
    const WEEK = 604800016;
    const MONTH = 2629800000;
  
    try {
      let snap = await firestore.collection(&quot;purchases&quot;).where(&quot;ErrorID&quot;, &quot;==&quot;, &quot;0&quot;).get(); // CONDITION
      let totalToday = 0;
      let totalYesterday = 0;
      let totalLastWeek = 0;
      let totalLastMonth = 0;
      let now = Date.now();
      let Yesterday = now - 86400000;
  
      await snap.forEach((doc) =&gt; { // THIS FOR EACH TAKES TOO MUCH TIME
        let info = doc.data();
        let time = info.Order.split(&quot;-&quot;)[2]; // FIRESTORE FIELD -&gt; ORDER
        let amount = info.AmountEur * 1; // FIRESTORE FIELD -&gt; AMOUNT
  
        if (time &gt; now - DAY) {
          totalToday = totalToday + amount;
        }
        if (time &lt; now - DAY &amp;&amp; time &gt; Yesterday - DAY) {
          totalYesterday = totalYesterday + amount;
        }
        if (time &gt; now - WEEK) {
          totalLastWeek = totalLastWeek + amount;
        }
        if (time &gt; now - MONTH) {
          totalLastMonth = totalLastMonth + amount;
        }
      });
  
      res.send({
        status: true,
        data: {
          totalToday: totalToday.toFixed(2),
          totalYesterday: totalYesterday.toFixed(2),
          totalLastWeek: totalLastWeek.toFixed(2),
          totalLastMonth: totalLastMonth.toFixed(2),
        },
      });
    } catch (error) {
      res.status(410).send({
        status: false,
        error: &quot;some error occured counting the numbers&quot;,
        e: error.message,
      });
    }
  };
  </code></pre>
  <p>The document im talking about</p>
  <p><img src="https://i.stack.imgur.com/bop3K.png" alt="The document im talking about" /></p>