title: How to get all items which are not part of a GSI?
body: <p>Imagine you have a dynamodb table with following properties (all strings):</p>
  <ul>
  <li><code>userId</code> &lt;- hash key</li>
  <li><code>companyId</code></li>
  <li><code>firstname</code></li>
  <li>etc..</li>
  </ul>
  <p>In this case it can be possible that the user has no <code>companyId</code> so it can be empty/non-existent for some db entries.</p>
  <p>Now you create a global secondary index (GSI) with the <code>companyId</code> as hash key.</p>
  <p><strong>Question</strong></p>
  <p>Is it possible  to query all db entries that have <em>no</em> <code>companyId</code> by using the GSI above? If no, what other options (without a <code>scan</code>) are there?</p>
  <p><strong>Considered option</strong></p>
  <p>Technically you could set all <code>companyId</code>'s to a value like <code>&quot;empty&quot;</code> but in my opinion that leads to a not so inutuitive coding experience since you would need to check <code>companyId == &quot;empty&quot;</code> instead of <code>companyId == null</code> (which is the usual and known way to check for empty variables).</p>