Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-632

getLastErrorDefaults example in docs for Write Concern can cause error

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • Server_Docs_20231030
    • None
    • manual
    • None

    Description

      The settings.getLastErrorDefaults example on the Write Concern page says:

      cfg = rs.conf()
      cfg.settings.getLastErrorDefaults = {w: "majority", j: true}
      rs.reconfig(cfg)

      This only works if there is a settings field in the cfg document already. Otherwise, the shell complains with an error:

      bla:PRIMARY> cfg = rs.conf()
      {
      	"_id" : "bla",
      	"version" : 3,
      	"members" : [
      		{
      			"_id" : 0,
      			"host" : "capslock.local:27017"
      		},
      		{
      			"_id" : 1,
      			"host" : "capslock.local:27018"
      		},
      		{
      			"_id" : 2,
      			"host" : "capslock.local:27019"
      		}
      	]
      }
      bla:PRIMARY> cfg.settings.getLastErrorDefaults = {w: "majority", j: true}
      Mon Oct 22 11:46:51 TypeError: cfg.settings has no properties (shell):1

      Attachments

        Activity

          People

            sam.kleinman Sam Kleinman (Inactive)
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              11 years, 17 weeks, 2 days ago