[JAVA-24] Collection find (with specified fields) needs javadoc comments Created: 26/Aug/09  Updated: 02/Oct/09  Resolved: 26/Aug/09

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 0.8

Type: Bug Priority: Minor - P4
Reporter: Ryan Nitz Assignee: Kristina Chodorow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

This method is not properly documented and there aren't any examples in the tutorial. At first, I tried to pass a DBList of the keys in. Please make sure to specify that you pass in an empty DBObject to the find method to walk all docs in the collection.

DBCursor find(DBObject ref, DBObject keys)

Here is my test/sample code:

final Mongo db = new Mongo("localhost", "myDb");
final DBCollection col = db.getCollection("myCollection");

final BasicDBObject keys = new BasicDBObject();
keys.put("_id", 1);

final DBCursor cur = col.find(new BasicDBObject(), keys);

while (cur.hasNext())

{ BasicDBObject doc = (BasicDBObject)cur.next(); for (final String field : doc.keySet()) System.out.println(field); }

I would also document that the _ns field is always returned.



 Comments   
Comment by Kristina Chodorow (Inactive) [ 26/Aug/09 ]

Added more docs and your example.

Generated at Thu Feb 08 08:51:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.