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

Collection find (with specified fields) needs javadoc comments

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 0.8
    • None
    • None
    • None

    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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: