Background
I’m developing a multi-tenant application using NestJS with NestJS-Query modules. Specifically, I need to implement schema-based multi-tenancy, where each tenant has its own database schema. I’m having difficulty integrating this approach with NestJS-Query.
What I’ve Researched
I’ve looked into:
- Creating dynamic database connections based on tenant
- Using custom connection factories
- Modifying NestJS-Query services to use tenant-specific connections
However, I’m unsure how to properly implement these ideas with NestJS-Query, which abstracts much of the database interaction.
My Questions
- Has anyone successfully implemented schema-based multi-tenancy with NestJS-Query modules?
- Are there any examples or open-source projects demonstrating this specific approach?
- How can I modify NestJS-Query services to connect to the correct tenant schema for each request?
- What’s the best way to handle database migrations across multiple tenant schemas when using NestJS-Query?
- Are there any performance considerations or best practices for schema-based multi-tenancy with NestJS-Query?
Additional Context
- I’m using TypeORM as my ORM
- Each tenant should have its own isolated schema
- I need to dynamically switch between schemas based on the incoming request
- I want to ensure that NestJS-Query’s features (like automatic CRUD operations) still work in this multi-schema environment
Any guidance, code snippets, or links to relevant resources would be immensely helpful. I’ve searched extensively but haven’t found clear examples of NestJS-Query being used in a schema-based multi-tenant application.