Boa noite.
Estou tentando fazer um insert usando Sequelize mas estou tendo problema no insert, pois aparentemente a quantidade de caracter esta impedindo o insert.
Quando eu faço o insert com poucos caracteres tenho sucesso, pois quando o campo de texto e muito long, me resulta um erro.
const Sequelize = require('sequelize');
const connection = require('./connection');
const members = connection.define('members',{
name: {
type: Sequelize.STRING,
allowNull: false
},
subject: {
type: Sequelize.STRING,
allowNull: false
},
consultant: {
type: Sequelize.STRING,
allowNull: false
},
record: {
type: Sequelize.TEXT('long'),
allowNull: false
}
});
members.sync({force: false});
module.exports = members;
ERRO APRESENTADO NO TERMINAL:
Executing (default): INSERT INTO
members
(id
,name
,subject
,consultant
,record
,createdAt
,updatedAt
) VALUES (DEFAULT,?,?,?,?,?,?); (node:5208) UnhandledPromiseRejectionWarning: SequelizeDatabaseError: Data too long for column 'record' at row 1 at Query.formatError (C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\dialects\mysql\query.js:239:16)
at Query.run (C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\dialects\mysql\query.js:54:18) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\sequelize.js:619:16 at async MySQLQueryInterface.insert (C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\dialects\abstract\query-interface.js:734:21) at async model.save (C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\model.js:3954:35) at async Function.create (C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\model.js:2207:12) (Usenode --trace-warnings ...
to show where the warning was created) (node:5208) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5208) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. Executing (default): INSERT INTOmembers
(id
,name
,subject
,consultant
,record
,createdAt
,updatedAt
) VALUES (DEFAULT,?,?,?,?,?,?); Executing (default): SELECTid
,name
,subject
,consultant
,record
,createdAt
,updatedAt
FROMmembers
ASmembers
WHEREmembers
.name
= 'teste' ORDER BYmembers
.createdAt
DESC; Executing (default): INSERT INTOmembers
(id
,name
,subject
,consultant
,record
,createdAt
,updatedAt
) VALUES (DEFAULT,?,?,?,?,?,?); (node:5208) UnhandledPromiseRejectionWarning: SequelizeDatabaseError: Data too long for column 'record' at row 1 at Query.formatError (C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\dialects\mysql\query.js:239:16)
at Query.run (C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\dialects\mysql\query.js:54:18) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\sequelize.js:619:16 at async MySQLQueryInterface.insert (C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\dialects\abstract\query-interface.js:734:21) at async model.save (C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\model.js:3954:35) at async Function.create (C:\Users\Bruno\Desktop\NODE PROJETOS\ultimoTreinamento\node_modules\sequelize\lib\model.js:2207:12) (node:5208) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)