Okay so, I want my app to have the following functionality :
A login that logs you in as a “customer” with specific customer specific info presented
A login that logs you in as a “Employee” that shows specific information about him/herself and the customers in the company.
I got it as far as having the dual login (so a user with the “customer” field set to true will login to the customer home screen and the same for employee)
But I actually wanted to create 2 types of users (customers and employees). Since this is not possible does anyone have idea’s for datastructures i could use ? I have been trying to have a collection of “Customer details” linked to customer and employee users and “employee details” linked to just employees but I noticed I can’t get the data correctly to their respective home screens.
Would I dump all different data (like employee nr, customer id, etc) in the users table and only fill in customer info for customers and only fill in employee info for employees or split this up ?
my current solution is just dumping all data about customers & employees into the users table and only filling in/showing data that belongs to either a customer or an employee. Also wondering if this solution is useful on the long run
One way is to use visibility conditions and filters based on a property in the users collection like a true/false that true for employer and false for customer. Also another way is to built two apps with the same DB for customer and employer!
Maybe @Victor , @theadaloguy , @Flawless , @axme can explain this better with some examples? ( Sorry guys for disturbing by tagging you’ll. Thought that you guys can help here as so much experienced makers! )
There are pros and cons for each approach (store everything in Users vs have separate tables for Customer details and Employee details) and there is no “one correct” solution here.
Personally I’m more leaned towards storing everything in Users. In my opinion it brings more advantages:
no need for an extra effort to make sure that data from other collections is available - you can use Logged-In User everywhere
less probability of mistakes when “simulating” 1:1 relationships between collections
simpler (and therefore a bit faster) query to the backend - an app need to get data only from one collection
Yes, you will have empty Employee fields for the Customers and vice versa. But you can easily manage that with conditional visibility (or, moreover, simply don’t display Employee fields in Customer section).
However: if you are using Collections Permissions + you are working with relatively sensitive data + you are creating a Webapp - then you need to store details in separate collections. But this is a separate topic.