how to create into n:m assocaition tables and avoid duplicate data in specific column (eg: unique field)

20 views
Skip to first unread message

Jyunhan Liou

unread,
Jan 10, 2017, 1:53:50 AM1/10/17
to Sequelize
Hi all
I'm trying to build my practice db environment in MySQL.
but how can I insert data into association tables and check if unique(or specific) field has duplicate value?

here are two situation
1. project sale new product (insert both)
2. project sale product, and the product was registed. 


I defined two models, set initial data into Product and associated them though "project_product" like following configure:
here is my current code:


then, I insert a data with duplicate product name like:


but it would occur SequelizeUniqueConstrainError exception here.

how can I insert data into association tables and check if unique(or specific) field has duplicate value?
Reply all
Reply to author
Forward
0 new messages