MongoDb schema Design for role based access

1.5k views Asked by At

I want to design a MongoDB schema where

  • There are multiple roles
  • There are multiple sites
  • users are mapped to sites with multiple roles like image below User Site Role Mapping

The DB Schema is as below for Permission

**permission**
id  
name
description

Role

**roles**
id
name
description
permission:[ids]

user

users
id
email
name
locationids:[ids]

unable to think through for

user_location_roles schema which will be easier to modify and easier to fetch from DB.

Please suggest schema that can be used

the UI for the site role user mapping is as below

enter image description here

0

There are 0 answers