我使用sequelize/w节点和node-mysql.
我使用sequelize-cli创建模型,结果如下:
'use strict';
module.exports = function(sequelize, DataTypes) {
let songs = sequelize.define('songs', {
name: DataTypes.STRING,
link: DataTypes.STRING,
artist: DataTypes.STRING,
lyrics: DataTypes.TEXT,
writer: DataTypes.STRING,
composer: DataTypes.STRING
});
return songs;
};
我希望能够为模型的每个属性定义排序规则和字符集.默认排序规则是'latin1_swedish_ci',我需要'utf-8'.
任何人?TNX
在你定义sequelize的部分
var sequelize = new Sequelize('database', 'username', 'password', { define: { charset: 'utf8', collate: 'utf8_general_ci', timestamps: true }, logging:false });
对于表级别更改
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' });