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

Java API only allows WriteResult.getN(), doesn't return nMatched, nUpserted, and nModified

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.12.1
    • Component/s: Write Operations
    • Labels:
      None

      When updating via Mongo Shell (MongoDB 2.6.0) we get 3 'n' numbers :

      bippo:PRIMARY> db.salesOrder.update({formalId: '100000001'}, {'$unset': {formalIdTrie: ''}});
      
      WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })
      

      However only `WriteResult.getN()` is provided by the Java API. From the mongo-java-driver 2.12.1 implementation :

          /**
           * Gets the "n" field, which contains the number of documents
           * affected in the write operation.
           * @return the number of documents modified by the write operation
           * @throws MongoException
           */
          public int getN(){
              return getLastError().getInt( "n" );
          }
      

      is it correct? Since there seems to be no n field in the WriteResult object when observed via Mongo shell.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ceefour Hendy Irawan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: