title: Find MongoDB object using value of another field
body: <p>I recently found difficulty in finding an object stored in a document with its key in another field of that same document.</p>
  
  <pre><code>{
      list : {
          "red" : 397n8,
          "blue" : j3847,
          "pink" : 8nc48,
          "green" : 983c4,
      },
      result : [
                  { "id" : 397n8, value : "anger" },
                  { "id" : j3847, value : "water" },
                  { "id" : 8nc48, value : "girl" },
                  { "id" : 983c4, value : "evil" }
               ]
      }
  }
  </code></pre>
  
  <p>I am trying to get the value for 'blue' which has an id of 'j3847' and a value of 'water'.</p>
  
  <pre><code>db.docs.find( { result.id : list.blue }, { result.value : 1 } );
  
  # list.blue would return water
  # list.pink would return girl
  # list.green would return evil
  </code></pre>
  
  <p>I tried many things and even found a great article on how to update a value using a value in the same document.: <a href="https://stackoverflow.com/questions/3974985/update-mongodb-field-using-value-of-another-field">Update MongoDB field using value of another field</a> which I based myself on; with no success... :/</p>
  
  <p><strong>How can I find a MongoDB object using value of another field ?</strong></p>