Hi MongoDB Community,
I’m building a multi-tenant SaaS application and want to allow users to create their own custom collections dynamically. For example, a user might create “Accounts” or “Leads” with custom fields.
My current approach is:
- A “CustomObjects” collection that stores metadata about user-defined collections.
Example fields: tenantId, label, description, isActive, etc. - A “`Fields” collection that defines the schema for each custom object.
Example fields: customObjectId, label, type (string, number, etc.), isActive, required, etc. - When performing crud. The Custom Object/Collection along with it’s fields will be query and used to create the model schema
Before I proceed, I’d love to get advice on:
- Is this the best approach, or should I use a different schema design?
- Are there performance concerns with querying data this way?
Looking forward to your insights! Thanks in advance.