I have a sales application built on the MERN stack with multiple roles (Admin, salesRep, Customer). Each role has specific data associated with it, so I have structured my MongoDB database with three models: User (common details), salesRep (sales representative details), and Customer (customer details).
The challenge I’m facing is managing relationships and aggregations across these models efficiently. For instance, when dealing with products, sales, or commissions, I often need to first find the User and then retrieve role-specific details from either the salesRep or Customer model. This leads to unnecessary aggregations and complexities.
Is there a more robust way to structure the database or handle these relationships to optimize performance and simplify queries across different roles in my application?