drizzle-seed
relationship with existing table
#4635
Unanswered
UOCDanBranch
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to be able to use Drizzle Seed to automatically populate a relationship foreign key where the relationship is being made to a table that has already been seeded.
As an example, imagine I have a table for posts, and a table for categories:
To my understanding the
with
property in the seeding refinement options would be generating new categories for every generated post:But my ideal seeding behaviour here would be to populate some dummy categories, then seed the posts by creating relationships to those already existing categories. As far as I can tell there isn't an idiomatic way to describe this within the seed config options. The best I've been able to come up with is:
valuesFromArray()
to populate the foreign key fields with the new IDs:All that said, my question is simply if this is the preferred method to do this, or whether I've overlooked something in the seed options.
Beta Was this translation helpful? Give feedback.
All reactions