sabinadams / nestjs-prisma-module

A NestJS module that allows you use Prisma, set up multiple Prisma services, and use multi-tenancy in each Prisma service.
50 stars 3 forks source link

How do you manage multi-tenant- I.e. Store permitted clients #34

Closed countrdd closed 2 months ago

countrdd commented 1 year ago

In the documentation, you talk about passing x-tenant-id in from a drop down list, where would you store such a list for multi-tenancy?

Would you need to have a master database that only systems admins could access to add and remove tenants?

sabinadams commented 2 months ago

The idea here is that you would have multiple identical databases named after the tenant. Say you have a white-labeled e-commerce and 3 companies using it. You would have 3 companies:

  1. Company1
  2. Company2
  3. Company3

This means you'd have three databases, say they're called:

  1. company-1
  2. company-2
  3. company-3

If Company2 accesses the API, they would pass x-tenant-id=company-2 in their header to get the correct database.