I am developing an app, which has multiple users (tenants), each of which has products, clients and appointments (lets say thats it). I am wondering how best to structure the mongoDb. Right now I have 3 options that come to mind:
- All products (for example) are in a single collection, where each item in the collection contains a tenantId
- For every tenant, I create a collection clients_tenantId, users_tenantId etc.
- For every tenant, I create a separate db where I put all the collections.
I have read the doc of mongodb, and it doesnt mention the 2nd option at all (why?), and according to it: if the number of tenants is in the hundreds, then option 3 is best, otherwise option 1. My problem with this is that I currently dont know the scale of my app and would like to “keep all options on the table”.
Also, if an option is best for large scale apps, why isnt it best (or close to it) for low scale apps?
Also, a use case may be later implemented where the “clients” of each tenant will be able to “access” their “tenants”..
In total, I am leaning towards the 1st option and implement JWT for security
Any suggestions and clarifications would be greatly appreciated!