DEV Community

Cover image for Create a multi-tenant application in Nest.js Part 3 (multi-database setup)

Create a multi-tenant application in Nest.js Part 3 (multi-database setup)

ismaeil-shajar on November 13, 2021

In part 1, we set up the nestjs framework and configured and tested microservices architecture application using nest.js. In part 2, we used Sequel...
Collapse
 
rikinotnull profile image
rikicmd

Are you going to continue to part 4?

Collapse
 
ismaeil_shajar profile image
ismaeil-shajar • Edited

Yes will be post next days

Collapse
 
verygreenboi profile image
Thompson Edolo

Would be interesting to see ABAC or PBAC implementation as opposed to just RBAC. Great tutorial.

Collapse
 
rikinotnull profile image
rikicmd

Thank you for the tutorial. I'm really waiting for part 4.

Thread Thread
 
ismaeil_shajar profile image
ismaeil-shajar
Collapse
 
faizershaikh profile image
Faizer Shaikh

it's great but what if I have used schema based separation and I have used public schema to store and manage information about all tenants and if I have some apis for public schema then it merges connections and gives wrong result to user and also if there are some paths or APIs on which we dont need sequelize connection then also it creates connection for that API,for eg; if we have public folder and we want to access a file from that folder at that time also it creates new sequelize connection

Collapse
 
alfianriv profile image
Alfian Rivaldi

I already create nestjs application Multi Tenancy with 1 connection database and multi schema
github.com/alfianriv/nestjs-multi-...

Collapse
 
ismaeil_shajar profile image
ismaeil-shajar

That nice you use poostgres right ?

Collapse
 
alfianriv profile image
Alfian Rivaldi

yes, i'm using postgres with multi schema

Collapse
 
andycharles6 profile image
andycharles6

Is it going to create a new connection for each request and destroy it after the request?

Collapse
 
ismaeil_shajar profile image
Info Comment hidden by post author - thread only accessible via permalink
ismaeil-shajar

yes because the injection scope is set to SINGLETON you can read more about in docs.nestjs.com/fundamentals/injec...

Collapse
 
ismaeil_shajar profile image
ismaeil-shajar

you are right I fix this and update post

Collapse
 
nileshmoradiya profile image
Nilesh

@ismaeil_shajar I really liked and enjoy the series. Any hints on when you're going to post the next article?

Collapse
 
crazyoptimist profile image
crazyoptimist

Thanks for the nice content!
Just a side question, how did you manage to auotmate sub domain creation when every tenant onboards?

Some comments have been hidden by the post's author - find out more