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

db.createRole() Example uses wrong format

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • None
    • manual
    • None

    Description

      The example for db.createRole() (http://docs.mongodb.org/manual/reference/method/db.createRole/#example), the write concern should be passed as a document in a separate argument not as part of the role document.

      use admin
      db.createRole({ role: "myClusterwideAdmin",
        privileges: [
          { resource: { cluster: true }, actions: [ "addShard" ] },
          { resource: { db: "config", collection: "" }, actions: [ "find", "update", "insert", "remove" ] },
          { resource: { db: "users", collection: "usersCollection" }, actions: [ "update", "insert", "remove" ] },
          { resource: { db: "", collection: "" }, actions: [ "find" ] }
        ],
        roles: [
          { role: "read", db: "admin" }
        ],
        writeConcern: { w: "majority" , wtimeout: 5000 }
      })
      

      I believe should be...

      use admin
      db.createRole({ role: "myClusterwideAdmin",
        privileges: [
          { resource: { cluster: true }, actions: [ "addShard" ] },
          { resource: { db: "config", collection: "" }, actions: [ "find", "update", "insert", "remove" ] },
          { resource: { db: "users", collection: "usersCollection" }, actions: [ "update", "insert", "remove" ] },
          { resource: { db: "", collection: "" }, actions: [ "find" ] }
        ],
        roles: [
          { role: "read", db: "admin" }
        ]},
        { w: "majority" , wtimeout: 5000 }
      )
      

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            dean.johnson@mongodb.com Dean Johnson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              8 years, 29 weeks, 4 days ago