Best Approach for Dynamic Custom Collections in a Multi-Tenant Ap

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:

  1. A “CustomObjects” collection that stores metadata about user-defined collections.
    Example fields: tenantId, label, description, isActive, etc.
  2. A “`Fields” collection that defines the schema for each custom object.
    Example fields: customObjectId, label, type (string, number, etc.), isActive, required, etc.
  3. 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:

  1. Is this the best approach, or should I use a different schema design?
  2. Are there performance concerns with querying data this way?

Looking forward to your insights! Thanks in advance.