Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-24

Collection find (with specified fields) needs javadoc comments

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 0.8
    • Affects Version/s: None
    • Component/s: None
    • None

      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.

            Assignee:
            kristina Kristina Chodorow (Inactive)
            Reporter:
            rn@deftlabs.com Ryan Nitz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: