Sequelize Migrate - Error: Typeerror: defineCall is not a Function

Asked

Viewed 290 times

0

Hello I’m doing a simple championship API, I used the Sequelize as ORM for my database.

I created the Arbitro table that had only the NAME field and did not have the CPF field in the table.

I had to include the CPF field in the Arbitro table and to do this I would have to use a migrate with Sequelize-CLI

After the sequelize db:migrate work, to run the project this giving error.

But when executing my project occurs the error below: inserir a descrição da imagem aqui

Here is the code: https://github.com/leonardocintra/campeonato-api

I searched on the net the cause of the error, but I am new to Nodejs and also each case was a case.

I appreciate anyone who can help. At.

1 answer

1


When you move your project up, in the db.js file it loads all your models and on line 39 it is trying to import a file that is not a "models/index.js model".

    const dir = Path.join(__dirname, 'models'); // Nessa linha ele carrega todos arquivos que devem ser apenas suas models.
    Fs.readdirSync(dir).forEach((file) => {
        const modelDir = Path.join(dir, file);
        const model = sequelize.import(modelDir);
        db.models[model.name] = model;
    });

Try removing this "models/index.js" file and running the project again, as apparently it is not needed in the project or is in the wrong place.

  • Thanks Lucas! It worked... I removed the index.js folder ... it was created by sequelize init and I thought I had to keep it

Browser other questions tagged

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