Complete the code to create a new role named 'readRole' with read-only privileges on the 'sales' database.
db.createRole({ role: 'readRole', privileges: [{ resource: { db: 'sales', collection: '' }, actions: ['[1]'] }], roles: [] })The 'read' action grants read-only access to the specified database or collection.
Complete the code to grant the built-in role 'readWrite' on the 'inventory' database to the user 'alice'.
db.grantRolesToUser('alice', [{ role: '[1]', db: 'inventory' }])
The 'readWrite' role allows both reading and writing data on the specified database.
Fix the error in the command to revoke the 'readWrite' role from user 'bob' on the 'reports' database.
db.revokeRolesFromUser('bob', [{ role: '[1]', db: 'reports' }])
The role to revoke is 'readWrite' to remove read and write permissions.
Fill both blanks to create a role 'customAdmin' with privileges to manage users and roles on the 'admin' database.
db.createRole({ role: 'customAdmin', privileges: [{ resource: { db: '[1]', collection: '' }, actions: ['[2]'] }], roles: [] })The 'admin' database is where user and role management happens, and 'userAdmin' action allows managing users and roles.
Fill all three blanks to create a role 'reportWriter' that can read from 'reports' and write to 'logs' databases.
db.createRole({ role: 'reportWriter', privileges: [{ resource: { db: '[1]', collection: '' }, actions: ['read'] }, { resource: { db: '[2]', collection: '' }, actions: ['[3]'] }], roles: [] })The role reads from 'reports' database and writes to 'logs' database using the 'write' action.