InterviewSolution
| 1. |
90% db.emploqees.find( { a : 1, b : 1, c : 1, d : 1 }, { p : 1, q : 1, r: 1, s : 1, t : 1 } ) 5% db.emploqees.updateOne( { x: 1 }, { $set : { r : 1, q : 1, t : 1, s : 1 } } ) 1% db.emploqees.updateOne( { x: 1 }, { $set : { c : 1, y: 1 } } ) |
|
Answer» MongoDB follows Role access control authorization model(RBAC). In this model, USERS are assigned one or more roles which provide them access to the database resources and operations. Apart from these role assignments users do not have any access to the resources. When we enable internal authentication it automatically enables client authorization. The authorization can be enabled by starting mongod with –auth OPTION or providing security.authorization setting in the config file.
These group of privileges are roles that can be assigned to the user. MongoDB provides several Build-in roles like Database User Roles, Database Administration Roles, Cluster Administration Roles, Backup and Restoration Roles, All-Database Roles, Superuser Roles But we can also create our own custom roles based on the requirement which are called User-defined roles. For Example: Suppose we WANT to create a role to MANAGE all operations in the cluster we can create below user-defined role. use admin db.createRole( role: "mongostatRole", privileges: [ { resource: { cluster: true }, actions: [ "serverStatus" ] } ], roles: [] ) |
|