title: How can I get only the objectId of document in mongodb using java
body: <p>I want to get only the objectId from mongodb with matched crieteria.I can get it with dbobject and cursor method.But I used mongo client here and have no idea how to do it.
  Thanking you</p>
  
  <pre><code>    MongoClient client = new MongoClient("localhost", 27017);
      MongoDatabase database = client.getDatabase("baazaronline");
      MongoCollection&lt;Document&gt; collection = database
              .getCollection("Attribute");
  
      Bson filter = new Document("attcode", attcode);
  
      Bson newValue = new Document("DefautV", DefautV).append("IVSO", IVSO).append("UniqueV", UniqueV).append("ValuesR", ValuesR).append("Visiblename", Visiblename).append("citso", citso).append("values",values);
      Bson updateOperationDocument = new Document("$set", newValue);
      collection.updateOne(filter, updateOperationDocument);
  
      client.close();
  </code></pre>