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

$all not working

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.4
    • Query Operations
    • Windows 7, MongoDB Java Driver v2.10.1, MongoDB v2.4.9

    Description

      The following code

      Test.java

      MongoClient client = new MongoClient();
      		DB db = client.getDB("school");
      		DBCollection collection = db.getCollection("students");
      		BasicDBList list = new BasicDBList();
      		list.add(new BasicDBObject("$elemMatch",
      				new BasicDBObject("type", "homework")));
      		BasicDBObject query = new BasicDBObject("scores", new BasicDBObject(
      				"$all", list));
      		System.out.println(query);
      		DBObject cursor = collection.findOne(new BasicDBObject(), query);
      		System.out.println(cursor);

      returns exception com.mongodb.MongoException: Unsupported projection option: $all
      although if you run the command that is printed out in the shell it returns a result without error.

      Steps to reproduce:

      • import the attached file in MongoDB
      • run the code

      Attachments

        Activity

          People

            trisha.gee@10gen.com Trisha Gee
            jarasez Mihaela Hetea
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: