In MongoDB / Meteor, what is the best way to manage role-based "tables"?


#1

I have been having a lot of trouble doing this lately and hoping someone can provide a bit of insight. I’m a beginner to mongodb/meteor. Mostly abstract.

So let’s just say I have a few roles, ['admin', 'teacher', 'student'], each having their own unique entry point into the application.

Now let’s say I have Settings. For each role, the settings will be different. For example, For a teacher role, the settings might look like this:

settings: {
  alerts: {
    assignmentSubmit: true,
    helpRequest: true
  },
  theme: {
    background: '#CCC',
    font: 'black',
    bannerUrl: 'https://fakesite.com/image.jpg'
  },
  discussionBoards: {
    allowStudentBoardsCreation: false,
    allowStudentThreadCreation: true,
    allowStudentCommentCreation: true,
    alertOnUpdate: false
  }
}

Now let’s say you look at settings for students.

settings: {
  defaultEmailAddress: 'email@email.com',
  receiveAlerts: true,
  receiveGradeUpdates: true
}

What I am really wondering is how to retrieve and access different information and schemas based on the role of the user in an extensible fashion. Any suggestions or tips?


#2

you should take a look at alanning:roles