I need to create a schema for a multi-user application that I need to develop using MongoDB, Express, AngularJS and NodeJS. I have 4 types of users in this application, GUEST , REGISTERED_USER , SUBSCRIBER , ADMIN . When a user has registered an application, I need to display forms and information based on the role (s) of a particular user.
Can someone give me some idea on how to handle the schema for different user roles, since I could subsequently use it for role functions and access level?
For example, for REGISTERED_USER , SUBSCRIBER , ADMIN users, registeredUserSchema is usually used:
var registeredUserSchema = mongoose.Schema({ userId: String, fullName: String , email: String, password: String, created: { type: Date, default: Date.now }, roles: [String] });
But then I need a lot of information requested from a user with the SUBSCRIBER role, so as soon as he registered in the application, I would like to display a lot of additional information to show that it is filled in his acocunt than the user with just REGISTERED_USER .
Can anyone help me with this?
EDIT: More explanation
For example, a REGISTERED_USER will have userId , but a user with the SUBSCRIBER role will have subscriberId . Therefore, I need to decide how to structure this data, since there is data common to all users, and then for each user there is different data based on his role. I need help with a data structure selection strategy. For example, in the Java Persistence API, we have various inheritance strategies for structuring data in relational database tables.