Need help with data architecture (multiple types of users)

Hi,

I’ve recently started working on a side project of mine. It involves having two separate types of users, Suppliers and Customers.

They need different sets of data to be stored, specifically Suppliers which have subscription / payment information stored. They also need to go through different sign-up flows in order to input said data.

I’m looking at the following options:

  1. Put all the extra data in the user profile, while adding an extra param, say “profile.type” to be either “supplier” or “customer”. But i think you shouldn’t put anything in the profile that you wouldn’t want the user editing.
  2. Having separate collections, while referencing them by userId. But doesn’t this decouple data which is logically coupled, as well as introduce an unnecessary “join” in the code?

How is it best to design the data given these constraints? Your help is much appreciated.

Thanks,
Bogdan

You could use another custom profile field in your user document if you don’t want to use the profile field itself.

But honestly, I would advise you to use either one or two separate collections and join them. It would allow you huge flexibility.

Take a look at the Meteor Guide which shows common ways of achieving this.

1 Like