createRole(role, writeConcern?)
This method creates a role in a database.
Note:
You can specify privileges for the role by explicitly listing the privileges or by having the role inherit privileges from other roles or both.
The role applies to the database on which you run the method.
db.createRole()
db.createRole({role: "myAdmin",privileges: [{ resource: { db: "config", collection: "" }, actions: [ "find", "update", "insert", "remove" ] }],roles: [{ role: "read", db: "admin" }]},{ w: "majority" , wtimeout: 5000 })
Output
{"role" : "myAdmin","privileges" : [{"resource" : {"db" : "config","collection" : ""},"actions" : ["find","update","insert","remove"]}],"roles" : [{"role" : "read","db" : "admin"}]}
No comments:
Post a Comment