I'm using nodejs and have a register page that has a select tag to choose between Client and Employee.
I want to have 1 Model and 2 Schemas: -User: will contains commun props eg:mail,name,pass... -EmployeeSchemma with specific fileds for an employee -ClientSchemma with specific fields for a client.
this is what In want to achieve in my server side :
var User=require("models/user");
router.post("/register",function(req,res){
var newUser=new User();
if(req.body.type=="client")
// make the newUser use the ClientSchema //
if(req.body.type=="employee")
// the newUser instance will use the EmployeeSchema //
});
Please how can I achieve such a result (?) note that I just want to use one single Model that can modelise both Client and Employee users depending on the user choice in the form .