Error when creating a bank with Sequelize

Asked

Viewed 454 times

1

Opa, I am creating a Rest API in Nodejs and using Sequelize as ORM only when I try to use the db:create command of the sequelize to create the database, it returns me this error:

ERROR: Dialect [Object Object] does not support db:create / db:drop

I wonder how I solve this problem, here comes the code:

module.exports = {
    dbconfig: {
        dialect: 'mysql',
        host: 'localhost:3306s',
        username: 'root',
        password: 'toor150',
        database: 'lynho_barber',
        define: {
            timestamps: true,
            underscored: true
        }
    },

};

The above code is the object that stores the sequelize parameter information

const Sequelize = require('sequelize');
const variables = require('../config/variables');

const connection = new Sequelize(variables.dbconfig);

module.exports = connection;

This above is the connection code of the sequelize.

2 answers

1

The problem is that you are not initiating Sequelize in the right way. Startup of Sequelize should be done as follows:

const sequelize = new Sequelize('database', 'username', 'password', { options });

In your case:

const connection = new Sequelize(
    variables.dbconfig.database,
    variables.dbconfig.username,
    variables.dbconfig.password,
    variables.dbconfig
);

See more examples on documentation.

  • tried this way and it also did not work. I tried to initialize in URI format and the error persists

  • The localhost:3306 has a s at the end. Your code is like this too or was typing error in the question?

  • was like this also in the code but I already corrected and the error continues

  • And the error remains the same? You have the package mysql2 installed?

-2

face the dialect that Voce is using in the mysql case, does not support db:create. do the following, update your npm , and reinstall the sequelize, restart your DBMS and if you have installed mysql2 reinstall it too, if not installed , install there.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.