Node, Sequelize, Mysql - How to define collation and charset to models? Node, Sequelize, Mysql - How to define collation and charset to models? express express

Node, Sequelize, Mysql - How to define collation and charset to models?


In the part where u define sequelize

var sequelize = new Sequelize('database', 'username', 'password', {  define: {    charset: 'utf8',    collate: 'utf8_general_ci',     timestamps: true  },  logging:false});

For Table level Changing

sequelize.define('songs', {  name: DataTypes.STRING,  link: DataTypes.STRING,  artist: DataTypes.STRING,  lyrics: DataTypes.TEXT,  writer: DataTypes.STRING,  composer: DataTypes.STRING}, {  charset: 'utf8',  collate: 'utf8_unicode_ci'});


is very simple to add utf-8 just go to any model that you have and do this for example (i edit your code):

module.exports = function(sequelize, DataTypes) {  let songs = sequelize.define('songs', {    name: {DataTypes.STRING,allowNull : false},    link: {DataTypes.STRING,allowNull : false},    artist: {DataTypes.STRING,allowNull : false},    lyrics: {DataTypes.TEXT,allowNull : false},    writer: {DataTypes.STRING,allowNull : false},    composer: {DataTypes.STRING,allowNull : false}  }, {charset: 'utf8', /* i add this two ligne here for generate the table with collation  = 'utf8_general_ci' test it and tell me ? */collate: 'utf8_general_ci'});  return songs;};