title: mongodb query where nested object has > 0 properties
body: <p>EDIT - See the end of the question for one way to do it:</p>
  
  <p>I have a mongo object with properties like:</p>
  
  <p><code>{ something: { name: "asdf", childThing: {} } }</code></p>
  
  <p>and </p>
  
  <p><code>{ something: { name: "jklh", childThing: {"type": "blah"} } }</code></p>
  
  <p>How can I write a query that will find the object <code>somethingElse</code> based on the fact that <code>count(somethingElse.childThing.keys) &gt; 0</code></p>
  
  <p>I tried this but it's only for arrays, I guess, because it returns all records:</p>
  
  <p><code>{ 'childThing': { $exists: true, $not: {$size: 0} } }</code></p>
  
  <p><strong>EDIT: I figured out one way to do this:</strong></p>
  
  <p><code>{ 'something.childThing': { $not: {$eq: {} } } }</code></p>
  
  <p>This just matches all documents that have a non-empty value for that child</p>