I'm creating a cms using MongoDb. I'm having trouble figuring out the basic modelling strategy and would appreciate some help.
The basic use case is just like many out there where each tenant can create their own schema - i.e. tenant1 can say "I want to have Products, and each product will have a Name, Description, Quantity, and a Price", while tenant2 could say "I want to have Bands, and each band will have a Name, HomeCity, MusicCategory, etc". Tenants could define multiple content types and also specify if a field is searchable. Tenants would then be able to create, update, and query entries of these types for use on their websites.
Here are the three solutions I've read about and seen presented and my concerns with each:
1. Have two collections, schema and data, and have all tenant's data together in these two collections. My main concern with this is the indexing/searching. If each tenant can create multiple unique data types and specify one or more fields in each as searchable, it seems like this would be a nightmare on the indexing.
2. Have the above pair of collections (schema and data) for each tenant. I've read that having tens of thousands of collections is generally a bad idea, but I don't understand exactly why or if WiredTiger makes any difference now. I also don't know if this would completely solve the indexing concerns that solution 1 has.
3. Create a database per tenant. If we plan on having tens of thousands of tenants, this seems untenable.
The front-runner so far is number 1, using a separate tool, like solr or elasticsearch, to handle querying the data.
Any thoughts or modelling strategies will be greatly appreciated. I know there are existing CMS's out there that use MongoDb and have these exact same features. I'd really like to know how they handle the indexing and querying of such widely unique data across tens of thousands of tenants.