title: mongo function and forEach complex query in java using MongoClient
body: <p>Can anyone help implement this in java using MongoClient.</p>
  
  <pre><code>"var arr = []
  db.getCollection("A").find().forEach(function(doc){arr.push(doc.AS)})
  db.getCollection("B").find( { _id: { $nin: arr}},{_id:1})"
  </code></pre>
  
  <p>From the above query i am trying to get only _id fields from "B" collection where the record in _id field of "B" does not matches to the "AS" field of "A" collection. </p>
  
  <p>This code written above works well in MongoShell.</p>
  
  <p>But i am not able to convert it in java driven script which uses MongoClient for conversion of queries and get value.</p>