Home > front end >  MongoDB Schema for multiple user types
MongoDB Schema for multiple user types

Time:02-15

There are three different user types in my application. 1.Creator 2.Company 3.Admin

The fields will be almost same for all the three,except there wont be full name for company.But there will be company name field.

 id: string;
 email: string;
 phone: string;
 password: string;
 user_type: string;
 full_name: string;
 company_name:string

Should I follow the same schema with single collection or 3 different collections for each user type ?

CodePudding user response:

In my experience, in situations like this it is usually better in the long term to stick with a single collection and then differentiate via queries. This allows you to easily add additional user types in the future (that you do not foresee now) without requiring adding more collections.

  • Related