Difference between privileges and roles

What is the difference between privileges and roles while create a new role,I am a little bit confused.
e.g.

db.createRole(
{
role: “insertAndFindTransactions”,
privileges: [
{
resource: { db: “transactions”, collection: “” },
actions: [ “insert”, “find”]
roles:[""]
}] } )

Can anyone tell me ?thanks

Hello @Zhao_Mian
please recheck the section on user defined roles at 1:30 and following. For short:
privileges define which actions can operate on which resources

A role is comprised of three components:

  • a name
  • a list of inherited roles
  • a list of privilege documents

For further reading you may start here and also utilize the provided link in the lecture notes

Regrads,
Michael

4 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.