Fra*_*ank 3 javascript mysql sql node.js sequelize.js
我有一个名为的简单MySQL表things.我的things表有三列:
Column Name Data Type
=========== ============
thing_id INT // The auto increment Primary Key
thing_name VARCHAR(255)
thing_size INT
Run Code Online (Sandbox Code Playgroud)
据我所知Sequelize.js期望/要求主键被命名为'id'.
有没有办法使用标准sequelize.define()调用来定义我的things表?如果没有,还有另一种方式吗?
尝试
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)
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2260 次 |
| 最近记录: |