How to refine seed data using `with` clause in drizzle seed

I have a table called workout that has a one-to-many relationship to another table called exercise (i.e one workout has many exercises associated with it). Now, when I try to seed some workouts, I want to be able to seed each workout with multiple exercises. I want to be able to refine what parameters are allowed for the nested exercises, but I see no way to do that. Here's what I have:
await seed(db, { workout, exercise }).refine((funcs) => ({
workout: {
count: 3,
columns: {
title: funcs.valuesFromArray({ values: workoutTitleList }),
},
with: {
exercise: 3,
},
},
}));
await seed(db, { workout, exercise }).refine((funcs) => ({
workout: {
count: 3,
columns: {
title: funcs.valuesFromArray({ values: workoutTitleList }),
},
with: {
exercise: 3,
},
},
}));
And here's what I want (but don't see that I can actually accomplish):
await seed(db, { workout, exercise }).refine((funcs) => ({
workout: {
count: 3,
columns: {
title: funcs.valuesFromArray({ values: workoutTitleList }),
},
with: {
exercise: {
columns: {
title: funcs.valuesFromArray({ values: predefinedListOfExerciseTitles })
}
}
},
},
}));
await seed(db, { workout, exercise }).refine((funcs) => ({
workout: {
count: 3,
columns: {
title: funcs.valuesFromArray({ values: workoutTitleList }),
},
with: {
exercise: {
columns: {
title: funcs.valuesFromArray({ values: predefinedListOfExerciseTitles })
}
}
},
},
}));
As you can see, I want to have a pre-defined set of exercises that are randomly chosen from and tied to each workout. So, what's the solution to making this happen?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?