Cannot bulk create in many to many association. #17289
Unanswered
azaelvaldo
asked this question in
Help & Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello! I would like to get help around this problem, i always use to create insert in bulk mode to seed my database, but this is the first time that i am trying to populate a many to many association.
This is my many to many association definition:
const Keywords = db.define('art_exhibition_keywords') Keyword.belongsToMany(ArtExhibition, { through: Keywords, as: 'artKeywords' }) ArtExhibition.belongsToMany(Keyword, { through: Keywords, as: 'artKeywords' })
this is my array of relations:
[ { "keyword_id": 6, "art_exhibition_id": "_vOAN-Q7~X" }, { "keyword_id": 7, "art_exhibition_id": "_vOAN-Q7~X" }, { "keyword_id": 2, "art_exhibition_id": "7lPK7ZUjtx" }, { "keyword_id": 3, "art_exhibition_id": "7lPK7ZUjtx" }, { "keyword_id": 5, "art_exhibition_id": "7lPK7ZUjtx" }, { "keyword_id": 8, "art_exhibition_id": "7lPK7ZUjtx" }, { "keyword_id": 3, "art_exhibition_id": "91381ekA91" }, { "keyword_id": 5, "art_exhibition_id": "91381ekA91" } ]
And i am using the bulkcreate for keywords:
await Keywords.bulkCreate(newData)
but i am getting this error and i dont know how to proceed:
Beta Was this translation helpful? Give feedback.
All reactions