javascript - Disable Primary Key in Sequelize JS - Stack Overflow

Is there a way to disable the automatic generated primary key inside Sequelize JS?We create our tables

Is there a way to disable the automatic generated primary key inside Sequelize JS?

We create our tables inside PostgreSQL using Sequelize's sync method. But we've a problem with our junction tables.... We don't want a primary key in our junction table, but Sequelize generates one automatically if we don't specify one our selves. I can specify a primary key on all columns, but that's not the best way to do it....

Anyone who knows how to disable primary keys inside Sequelize JS?

Is there a way to disable the automatic generated primary key inside Sequelize JS?

We create our tables inside PostgreSQL using Sequelize's sync method. But we've a problem with our junction tables.... We don't want a primary key in our junction table, but Sequelize generates one automatically if we don't specify one our selves. I can specify a primary key on all columns, but that's not the best way to do it....

Anyone who knows how to disable primary keys inside Sequelize JS?

Share Improve this question asked Oct 17, 2014 at 8:39 Erik van de VenErik van de Ven 5,0056 gold badges45 silver badges85 bronze badges 3
  • where you able to find a solution for this? – user1130272 Commented Apr 28, 2015 at 11:04
  • 1 Well we don't use the sync method anymore. We create new tables and edit them by using the migrations of Sequelize. So after every deployment we directly deploy new changes for our DB. And in our models we use posite primary keys for the junction tables. So just add primaryKey: true to multiple columns, whose bination makes them unique. So the users table has an column id as primary key, books has an column id as primary key. But user_books (= junction table) has 2 primary keys: user_id and book_id Not how we want it, but works best. – Erik van de Ven Commented Apr 29, 2015 at 12:41
  • Thanks so much, i was struggling with the same since yesterday and did not find a solution, Thanks again i will go your way – user1130272 Commented Apr 29, 2015 at 13:31
Add a ment  | 

1 Answer 1

Reset to default 5
Model.removeAttribute("id");

More documentation removeAttribute

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745562994a4633220.html

相关推荐

  • javascript - Disable Primary Key in Sequelize JS - Stack Overflow

    Is there a way to disable the automatic generated primary key inside Sequelize JS?We create our tables

    14小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信