2017-01-30 140 views
0
sequelize model:create --name tasks --force --attributes "title:string,description:text, data_type:text, shift:str 
ing, date:date, start_time:time, end_time:time, type:string, location:string, visible_to_helpers:date, reminders_to_helpers:integer, created_date:time, modifi 
ed_date:time" 

我试过了。它的工作,但它创建id主键,我想一些TASK_ID如何使用自定义名称在sequelize-cli中定义自定义主键

但是当我试图这样它给了我错误

equelize model:create --name tasks --force --attributes "task_id:{type:integer, primaryKey: true,autoIncrement: 
true}, title:string,description:text, data_type:text, shift:string, date:date, start_time:time, end_time:time, type:string, location:string, visible_to_helpe 
rs:date, reminders_to_helpers:integer, created_date:time, modified_date:time" 

,并在所有的小写字母

感谢的情况下无法正常工作

这里是错误

enter image description here

回答

0

我有同样的问题,我用哈克的方式解决它。创建模型后(如第一个命令),它使id成为主键。所以我更新的模式,“别的东西”作为我的主键,运行以下命令:

node_modules/.bin/sequelize db:migrate 

它为我工作。下面是我遵循的指导原则链接:

http://mherman.org/blog/2015/10/22/node-postgres-sequelize/#.WWUr49MrIsk