'Create different types (3) of users in MongoDB

this is my first post here, and moreover I use google translate to communicate with you, please excuse me if I am not understandable

I am also new to programming and I am stuck on the organization of my user models, I would like to have your opinions,

I would like that when creating a user, this one has the choice between 3 categories which will display a form accordingly,

for example, when I register on the site, I can choose my status (employee, manager, client) and depending on the chosen status, the data recorded in my database will be different,

I was thinking of using a common base for all users ("email", "password") then depending on the box checked, new fields will appear as ("name", "birth", etc..) for "Client" , or (" name", "lastName", "picture", etc..) for "Employee" and another schema for "Manager"

I tried the populate function with the different schema (employee, manager, client), is this the right direction?

a picture is worth a thousand words

example front

thank you for taking the time to read me, best regards



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source