title: using $exists in Mongo with dynamic key names and the native driver for node
body: <p>I have a document in a collection like so:</p>
  
  <pre><code>{
    container : {
      P39433: 2,
      P30213: 4
    }
  }
  </code></pre>
  
  <p>The values 'P39433' and 'P30213' are dynamically generated in the program. I can run the following query using the dot notation against mongo directly and I get the desired result</p>
  
  <pre><code>db.collection.findOne({ "container.P00000" : { $exists : false } }) 
  </code></pre>
  
  <p>I get the document back. i.e. I only want to get the document if the field does not exist.</p>
  
  <p>My question is how can I run that query in Node using the native driver when the value <code>P00000</code>
  is contained in a variable.</p>
  
  <p>My usual solution is to structure the query like below but it does not return a result.</p>
  
  <pre><code>var fieldName = 'P00000';
  var dynObj = {};
  dynObj[fieldName] = { $exists : false };
  db.collection.findOne( { "container" : dynObj }); 
  </code></pre>