[DOCS-632] getLastErrorDefaults example in docs for Write Concern can cause error Created: 22/Oct/12  Updated: 30/Oct/23  Resolved: 22/Oct/12

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Minor - P4
Reporter: Thomas Rueckstiess Assignee: Sam Kleinman (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 11 years, 17 weeks, 2 days ago

 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



 Comments   
Comment by auto [ 22/Oct/12 ]

Author:

{u'date': u'2012-10-22T06:53:34-07:00', u'email': u'samk@10gen.com', u'name': u'Sam Kleinman'}

Message: DOCS-632: minor java script syntax correction
Branch: master
https://github.com/mongodb/docs/commit/a1f78f31b6ab8efe66c314b21737df4a758193ef

Generated at Thu Feb 08 07:39:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.