Configure API for SQL Server database

1

I have an API that I used with MySQL, but I had to switch to SQL Server. Unfortunately I've never used SQL Server, I do not know if I need to download something to get it. The API was done in JS. The configuration of the sequelize of my API with MYSQL was like this:

const Sequelize = require('sequelize');    

const config = {
    user: "root",
    database: "api",
    password: "",
    host: "localhost",
    port: 3306,
    dialect: 'mysql',
    max: 10000,
    idleTimeoutMillis: 3000
};

const seq = new Sequelize(
    config.database,
    config.user,
    config.password,
    {
        host:config.host,
        dialect:config.dialect,
        port:config.port,
        logging: false,
        pool: {
            max: config.max,
            min: 0,
            idle: config.idleTimeoutMillis
        }
    }
);

module.exports = seq

I made the following change to test with sql server:

const Sequelize = require('sequelize');    

const config = {
    user: "sa",
    database: "dbPortal",
    password: "",
    host: "localhost",
    port: 1433,
    dialect: 'mssql',
    max: 10000,
    idleTimeoutMillis: 3000
};

const seq = new Sequelize(
    config.database,
    config.user,
    config.password,
    {
        host:config.host,
        dialect:config.dialect,
        port:config.port,
        logging: false,
        pool: {
            max: config.max,
            min: 0,
            idle: config.idleTimeoutMillis
        }
    }
);

module.exports = seq

When I call the API it says it was connected, but then it says it was not. When I test it, it is POST, it gives some red errors in the prompt.

Does anyone know how to configure it to work in SQL Server?

    
asked by anonymous 08.03.2018 / 13:02

1 answer

0

With the help of the comments in my question I was able to solve:

const config = {
    user: "sa",
    database: "Nomedb",
    password: "",
    host: "GUI122", //NOME QUE APARECE ANTES DA INSTANCIA DO MEU SQL
    port: 1433, //PORTA PADRAO SQL SERVER
    dialect: 'mssql',
    max: 10000,
    idleTimeoutMillis: 3000,
    instanceName: 'MSSQLSERVERMARIA' //INSTANCIA DO MEU SQL SERVER

};
    
15.03.2018 / 13:33