title: How do you calculate the average of a all entries in a field from a specific collection in Mongo using Ruby
body: <p>Given the following data:</p>
  
  <pre><code>{
    _id: ObjectId("51659dc99d62eedc1a000001"),
    type: "image_search",
    branch: "qa_media_discovery_feelobot",
    time_elapsed: 19000,
    test: "1365613930 All Media",
    search_term: null,
    env: "delta",
    date: ISODate("2013-04-10T17:13:45.751Z")
  }
  </code></pre>
  
  <p>I would like to run a command like:</p>
  
  <pre><code>avg_image_search_time = @coll.find("type" =&gt; "image_search").avg(:time_elapsed)
  </code></pre>
  
  <p>How would I accomplish this?</p>