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

Restore the detailed JSON return document the getLastError used to return

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.0.2
    • Component/s: None
    • None
    • QE 2022-11-28, QE 2022-12-12

      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.

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

              Created:
              Updated:
              Resolved: