title: Raw javascript mongodb queries using db.eval() in java
body: <p>currently I'm working on a project in JAVA, and I need to run the Javascript Mongo queries through JAVA, and I figured I can do something like that using db.eval() in java. Problem is I have the following Javascript query for Mongo, and I have no idea how can I pass the whole Script to the db.eval() method. Any idea ? please let me know. 
  thank you </p>
  
  <pre><code>    var red = function(doc, out) {
      out.count_order++;
      out.sum_qty += doc.quantity;
      out.sum_base_price += doc.extendedprice;
      out.sum_disc_price += doc.extendedprice * (1 - doc.discount);
      out.sum_charge += doc.extendedprice * (1 - doc.discount) * (1 + doc.tax);
      out.avg_disc += doc.discount 
      };
      var avg = function(out) {
      out.avg_qty = out.sum_qty / out.count_order;
      out.avg_price = out.sum_base_price / out.count_order;
      out.avg_disc = out.avg_disc / out.count_order 
      };
      db.deals.group( {
      key : { RETURNFLAG : true, LINESTATUS : true},
      cond : { "SHIPDATE" : {$lte: new Date(1998, 8, 1)}},
      initial: { count_order : 0, sum_qty : 0, sum_base_price : 0, sum_disc_price : 0,
      sum_charge : 0, avg_disc : 0},
      reduce : red,
      finalize : avg
      });
  </code></pre>