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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.12.1
    • Write Operations
    • None

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: