title: Running custom mongodb queries in java
body: <p>I want to run raw mongoDb queries using runCommand() which takes in BSON data. 
  Following is my code</p>
  
  <pre><code>    MongoClient mongoClient = new MongoClient();
      MongoDatabase database = mongoClient.getDatabase("MyDB");
      MongoCollection&lt;Document&gt; collection = (MongoCollection&lt;Document&gt;)database.runCommand(??);        
  </code></pre>
  
  <p>If my query is</p>
  
  <blockquote>
    <p>db.mycol.find({"by":"tutorials point"}).</p>
  </blockquote>
  
  <p>What should be BSON data that I have to pass inside runCommand() ? Is it only </p>
  
  <blockquote>
    <p>{{"by":"tutorials point"}}</p>
  </blockquote>
  
  <p>or </p>
  
  <blockquote>
    <p>db.mycol.find({"by":"tutorials point"}).</p>
  </blockquote>
  
  <p>And If instead of find() i have to use Insert() how to go about it ??</p>