0
0
MongoDBquery~10 mins

Custom role creation in MongoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a custom role named "readWriteReports".

MongoDB
db.createRole({ role: "readWriteReports", privileges: [], [1]: ["read"] })
Drag options to blanks, or click blank then click option'
Apermissions
Bactions
Croles
Dusers
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'actions' instead of 'roles' causes an error.
Leaving out the roles field results in incomplete role definition.
2fill in blank
medium

Complete the code to add a privilege that allows reading from the "reports" collection.

MongoDB
db.createRole({ role: "readReports", privileges: [{ resource: { db: "analytics", collection: "reports" }, [1]: ["find"] }], roles: [] })
Drag options to blanks, or click blank then click option'
Aactions
Bprivileges
Cpermissions
Droles
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'permissions' instead of 'actions' causes the role to not work.
Putting 'actions' outside the privilege object causes syntax errors.
3fill in blank
hard

Fix the error in the role creation by completing the missing field for resource specification.

MongoDB
db.createRole({ role: "writeLogs", privileges: [{ [1]: { db: "logsDB", collection: "logs" }, actions: ["insert", "update"] }], roles: [] })
Drag options to blanks, or click blank then click option'
Atarget
Bresources
Cprivilege
Dresource
Attempts:
3 left
💡 Hint
Common Mistakes
Using plural 'resources' causes the command to fail.
Using 'privilege' or 'target' is invalid in this context.
4fill in blank
hard

Fill in the blank to create a role that inherits from "read" and "write" roles.

MongoDB
db.createRole({ role: "readWrite", privileges: [], [1]: ["read", "write"] })
Drag options to blanks, or click blank then click option'
Aroles
Bprivileges
Cactions
Dpermissions
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'privileges' or 'actions' instead of 'roles' causes errors.
5fill in blank
hard

Fill all three blanks to create a role with a privilege allowing "remove" action on "temp" collection in "testDB".

MongoDB
db.createRole({ role: "tempRemover", privileges: [{ [1]: { db: [2], collection: [3] }, actions: ["remove"] }], roles: [] })
Drag options to blanks, or click blank then click option'
Aresource
B"testDB"
C"temp"
D"logsDB"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong field name instead of 'resource' causes failure.
Using wrong database or collection names causes unexpected behavior.