Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-71197

Restore the detailed JSON return document the getLastError used to return

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • None
    • 6.0.2
    • None
    • None
    • QE 2022-11-28, QE 2022-12-12

    Description

      Prior to version 5.1, getLastError, db.getLastError(), or db.getLastErrorObj() could be used to get detailed information about the success or failure of write operations:

        mongo << host/port/user etc >> --quiet 
              --eval "db.ValidProducts.drop();printjson(db.runCommand( { getLastError: 1 } ));"

        {
          "connectionId" : 2869,
          "n" : 0,
          "syncMillis" : 0,
          "writtenTo" : null,
          "err" : null,
          "ok" : 1

      {\{  }

      }}

      In MongoDB version 6.0, getLastError was removed and write commands often only return a boolean, instead of the detailed JSON output:

        mongosh << host/port/user etc >> --quiet 
                --eval "var drc = db.ValidProducts.drop(); printjson(drc)"
        false

       

      This request is to restore the ability to get more detailed return documents from write operations.

      Attachments

        Activity

          People

            david.storch@mongodb.com David Storch
            william.byrne@mongodb.com William Byrne III
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: