title: MongoDB + Node JS + Role Based Access Control (RBAC)
body: <p><strong>Am currently learning MEAN</strong> stack, developing a simple TODO's app and want to implement Role Based Access Control (RBAC) for that. How do i set up roles &amp; permission on MongoDB. </p>
  
  <p>I want 3 roles (roles may look funny but this is purely to learn) : </p>
  
  <ul>
  <li>GOD </li>
  <li>SUPER HERO</li>
  <li>MAN</li>
  </ul>
  
  <p><strong>GOD</strong> - similar to super admin, can do anything in the application. C,R,U,D permissions for TODO's and for other users too. Can Create a TODO &amp; assign it to any SUPER HERO or MAN directly. Update or Delete either a TODO or a User at any point in time.</p>
  
  <p><strong>SUPER HERO</strong> - similar to admin, has super power to do anything on his personal Data - C,R,U,D for TODO's. Can't create any users. Can only Read &amp; add comments for TODO's created by GOD &amp; assigned to him/her.</p>
  
  <p><strong>MAN</strong> - Can only Read and add comments to TODO's assigned to him/her. </p>
  
  <p>To sum it up :</p>
  
  <p><code>GOD - C,R,U,D [Global Level]
  SUPER HERO - C,R,U,D [Private] + R,U [Assigned to him]
  MAN - R,U [Assigned to him]</code></p>
  
  <p>I understand that i need to have USERS &amp; ROLES collections. Where ROLES inturn should have PERMISSIONS etc. How do i wire them all ?</p>