title: Firestore - get specific fields from document
body: <h2>What I need:</h2>
  
  <p>I want to save articles or notes in Firestore with their respective fields:</p>
  
  <ul>
  <li>Title</li>
  <li>Content (texts or paragraphs)</li>
  <li>Creation date</li>
  <li>Owners (to share that article with other
  people and who can edit them like: <a href="https://firebase.google.com/docs/firestore/solutions/role-based-access" rel="noreferrer">https://firebase.google.com/docs/firestore/solutions/role-based-access</a>)</li>
  </ul>
  
  <p>But when I show the list of articles I don't need the "content" field (to save bandwidth). I've read that (maybe I'm wrong), it is not possible to make a query to get only specific fields from a document with Firestore.</p>
  
  <p>If it were normal SQL to obtain specific columns from articles (without its content) It would be something like:</p>
  
  <pre><code>SELECT title, creation_date, ...
  FROM table_name;
  </code></pre>
  
  <p>So I've opted to separate the content for two root-level collections (for flexibility and scalability) </p>
  
  <hr>
  
  <h2>My current structure:</h2>
  
  <p>Articles collection:</p>
  
  <pre><code>  - `articles` [collection]
      - `ARTICLE_ID` [document]
        - `creatorId` [field]
        - `title` [field]
        - `date` [field]
        - `owners` [obj field]
            - {user1_id}: true
            - {user2_id}: true
            ...
  </code></pre>
  
  <p>Contents collection:</p>
  
  <pre><code>  - `contents` [collection]
      - `{ARTICLE_ID}` [document]
        - `content` [field]
  </code></pre>
  
  <p>To get articles list in realtime:</p>
  
  <pre><code>firebase.firestore().collection('articles')
    .where(`owners.${user.uid}`, '==', true)
    .onSnapshot(querySnapshot =&gt; {
      const articles = []
      querySnapshot.forEach((doc) =&gt; {
        articles.push({
          id: doc.id,
          ...doc.data()
        })
      })
      // do something with articles array
    })
  </code></pre>
  
  <p>To show in another view and get the entire article with its content:</p>
  
  <pre><code>const db = firebase.firestore()
  const articleRef = db.collection('articles').doc(articleId)
  const contentRef = db.collection('contents').doc(articleId) // same Id as article
  
  articleRef.get().then(articleDoc =&gt; {
    if (articleDoc.exists) {
      contentRef.get().then(contentDoc =&gt; {
        if (contentDoc.exists) {
          const article = {
            ...articleDoc.data(),
            ...contentDoc.data()
          }
          // full article obj
        }
      })
    } 
  })
  </code></pre>
  
  <hr>
  
  <h2>My questions</h2>
  
  <ul>
  <li><p>Do you think it's better to do two queries (getArticle and getContent) at the same time and wait with Promise.all() instead of nesting the querys like I do?</p></li>
  <li><p>Is there a better way to get the article and its content with one query or more efficiently? Some tips or ideas?</p></li>
  </ul>
  
  <p>Thank you very much in advance!</p>