我有一个名为things
的简单MySQL表。我的things
表有三列:
Column Name Data Type
=========== ============
thing_id INT // The auto increment Primary Key
thing_name VARCHAR(255)
thing_size INT
据我所知,Sequelize.js期望/要求将主键命名为' id'。
有没有办法使用标准sequelize.define()
调用来定义我的things
表?如果没有,还有另一种方式吗?
答案 0 :(得分:6)
试
var Test = sequelize.define( 'things', {
thing_id : {type: Sequelize.INTEGER(11), primaryKey: true, autoIncrement: true},
thing_name : {type: Sequelize.STRING(255)},
thing_size : {type: Sequelize.INTEGER}
},{
});
Test.sync()
.success(function(){
console.log('table created');
})
.error(function(error){
console.log('failed', error)
})