title: mongodb shell query with javascript
body: <p>I have a key-value pair in my database which is like this - </p>
  
  <pre><code>{ 
    "class" : 
         {
           "name-class" : "working"
           "other-class" : "not working"
          }
  }   
  </code></pre>
  
  <p>I am trying to run a query with forEach loop which is like below - </p>
  
  <pre><code>db.collection.find({ "key" : "value" }).forEach(function(collection) {
      print ( collection.class.name-class );
  })
  </code></pre>
  
  <p>I am getting reference error for above. What I understood that it is not able to understand "name-"</p>
  
  <p>I have tried to use escape character as "-", ['name-class'] etc, but nothing is working. </p>
  
  <p>Can you please help me to form a correct query ?</p>
  
  <p>Also, can you please guide, how we can form the query in better way?</p>