title: How do I get documents where a specific field exists/does not exists in Firebase Cloud Firestore?
body: <p>In Firebase Cloud Firestore, I have "user_goals" in collections and goals may be a predefined goal (master_id: "XXXX") or a custom goal (no "master_id" key)</p>
  
  <p>In JavaScript, I need to write two functions, one to get all predefined goals and other to get all custom goals.</p>
  
  <p>I have got some workaround to get custom goals by setting "master_id" as "" empty string and able to get as below:</p>
  
  <pre><code>db.collection('user_goals')
      .where('challenge_id', '==', '')  // workaround works
      .get()
  </code></pre>
  
  <p>Still this is not the correct way, I continued to use this for predefined goals where it has a "master_id" as below</p>
  
  <pre><code>db.collection('user_goals')
      .where('challenge_id', '&lt;', '')  // this workaround
      .where('challenge_id', '&gt;', '')  // is not working
      .get()
  </code></pre>
  
  <p>Since Firestore has no "!=" operator, I need to use "&lt;" and ">" operator but still no success.</p>
  
  <p><strong>Question: Ignoring these workarounds, what is the preferred way to get docs by checking whether a specific field exists or does not exists?</strong></p>