title: How to "populate" in Firestore?
body: <p>I'm new with Firestore and I'm trying to migrate a MongoDB project to Firestore. I have the following issue. My data structure is this one:</p>
  
  <pre><code>/products
      'A': {name: 'Product A', price: 1},
      'B': {name: 'Product B', price: 2}
  
  /profiles
      '1': {name: 'John', purchases: [ {product: 'A', quantity: 1} ] }
  </code></pre>
  
  <p>I have a collection of products and a collection of profiles. These profiles have an array of purchases, and each purchase has a object reference to the corresponding product and a quantity. With MongoDb I could do this:</p>
  
  <pre class="lang-js prettyprint-override"><code>const profiles = await Profiles.findById('1').populate('purchases.product', 'name price');
  </code></pre>
  
  <p>So I could get the following object:</p>
  
  <pre><code>{
      _id: '1',
      name: 'John',
      purchases: [
          {
              {
                  _id: 'A',
                  name: 'Product A',
                  price: 1,
              },
              quantity: 1,
          }
      ]
  }
  </code></pre>
  
  <p>So with one query I can get all the purchases, I don't have to iterate through all purchases and get them by id. How can I achieve the same performance with Firestore? Also if this data model doesn't work as well with Firestore please tell me.</p>