September 2018
Beginner to intermediate
192 pages
4h 37m
English
You can use the db.createRole(<role document>) method to create custom roles. The role document fields include the following:
| Role | Name of the new role |
| privileges | Identifies the resource and actions. Resource identifies the database and/or collection. |
| roles | Any built-in or already-existing roles. |
| authenticationRestrictions | Whitelist allowed IP addresses or CIDR (Classless Inter-Domain Routing, https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) ranges (optional). |
In the following example, we are creating a role purchases which only allows create, read, update, and delete operations on the purchases collection. Otherwise, this role is allowed to read from the sweetscomplete database. This role also restricts ...
Read now
Unlock full access