Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
Choose one instance of sequelize conditionally to connect to mysql db

I have a use case where I need to create two schemas in production mysql database.I am connecting to these schema via sequelize from NodeJs.

I managed to create two instances of sequelize referring this, however the problem now is , how would I conditionally choose one of the two schema based on client side.As per the requirement, its my client who will decide which schema need to be used.There might be a variable being passed in the headers of request.How to read this on the server side and choose once instance of the sequelize conditionally.Please help as I am a newbie to this.

This is my code which is present in app.ts which connects to db, my use case is to call either of the two connection based on the flag passed from client side.

private connectToDatabase() {
   DB1.sequelize.sync({ force: false });
   DB2.testSequelize.sync({ force: false });
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!