title: Getting MongoDB Result from Raw Query With Java
body: <p>I'm trying to get a feel for how fast MongoDB is compared to traditional RDBMSs.  To this end, I'm using Java to try and get the result of a traditional SQL join by defining a MongoDB function that will return an object after embedding another object into it:</p>
  
  <pre><code>s_with_user = function(rows){
    var result=[]
    db.subscriptions.find().limit(rows).forEach( function(s) { 
      s.user= db.users.find({id: s.user_id});
      result.push( s );
    });
    return result;
  }
  </code></pre>
  
  <p>Then, I use:</p>
  
  <pre><code>DB db = new Mongo("localhost", 27017).getDB("test");
  Object result = db.eval("s_with_user(1000)");
  </code></pre>
  
  <p>Measuring the time taken for the last statement, I'm confident that MongoDB is running the command and evaluating the data I want.  However, the <code>result</code> object is always <code>null</code>.</p>
  
  <p>How can I do this in such a way that I can inspect the results?</p>