Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
Connect to Multiple Databases on one Server Using MSSQL NPM Package

I have a server set up and I am using "mssql" npm package to set up the database connections for my query routes. I want just one route in the whole server to be using a different database that is at a different IP address than the rest of the routes.

I have two different configs, configA and configB. This is my route set up:

router.get("/:code", function (req, res) {
  var sql = require("mssql");

    sql.connect(configA/B, function (err) {
      if (err) console.log(err);

      var request = new sql.Request();

      request.query("some query",
        function (err, recordset) {
          if (err) console.log(err);

          res.send(JSON.stringify(recordset));
        }
      );

    });

});

However, if I go to a page that uses a route with configA and then navigate to a page that uses a route with configB, configA just remains as the config, if that makes sense. I really just want to be able to use configA for routes 1, 2, and 3, and configB for route 4, but I am not able to as it always takes the already existing config.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda