Unhandledpromiserejectionwarning: Sequelizedatabaseerror: Table 'salao. Users' doesn’t exist

Asked

Viewed 830 times

0

Good morning, I’m facing the following problem

Executing (default): INSERT INTO `Users` (`id`,`name`,`email`,`avatar`,`password_hash`,`provider`,`createdAt`,`updatedAt`) VALUES (DEFAULT,?,?,?,?,?,?,?);
(node:3215) UnhandledPromiseRejectionWarning: SequelizeDatabaseError: Table 'salao.Users' doesn't exist

As we can see he is trying to insert in a table called "Users", the problem is that in BD the table is called "users" (with the lowercase initial). I’m using Mysql, Nodejs and Sequelize.

2 answers

1

The recommended is to use the option tableName when declaring your Model.

sequelize.define('users', { 
  id: Sequelize.INTEGER,
  name: Sequelize.STRING,
  ...
}, {
   tableName: 'users'
});
  • 1

    This tabletop solution worked perfectly for me. on 12/23/2020.

0

In your table model, after listing all fields, add:

adicionefreezeTableName: true

Browser other questions tagged

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