Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

106
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda