Skip to content

This project contains the setup of Multitenant (multiple database) connection in Sequelize-NodeJS-Postgres. It will help you understand in connecting multiple DBs using Sequelize. So, that single model is used to connect multiple DBs. You will understand the concept of slug here. Slug is used to identify the respective DB among multiple DBs. Slu…

Notifications You must be signed in to change notification settings

hirenpanchal1401/multitenant-app-node-sequelize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PROJECT SETUP

git clone https://github.com/hirenpanchal1401/multitenant-app-node-sequelize.git

npm install


DATABASE SETUP

1. common_db

Database which holds the information about all the tenant databases. It also stores the configuration for each tenant databases (in 'tenants' table) which can be used to enable/disable features for each tenant.

set config of common_db in .env file

FIELDS IN TABLE (TENANTS)

- id
- db_host
- db_port
- db_name
- db_dialect
- db_username
- db_password
- slug

2. tenant_db

Separate database for every tenant that holds data as per tenant needs.This should be same as a db_name field of tenants table of common_db.

Ex. tenant_db1 , tenant_db2

3. Different Tables In Tenant DBs

Create new tables with same fiels in all tenant database as per your requirement.

Ex. users table for tenant_db1 , tenant_db2 having same field

RUN PROJECT

npm start

About

This project contains the setup of Multitenant (multiple database) connection in Sequelize-NodeJS-Postgres. It will help you understand in connecting multiple DBs using Sequelize. So, that single model is used to connect multiple DBs. You will understand the concept of slug here. Slug is used to identify the respective DB among multiple DBs. Slu…

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published