one-to-many
I might be asking something simple or have to change my model but I thought I'd ask cause I've been stuck for a while.
I have an images table
you can see I have a resourceId and a resourceType because I have different things that can have relations to images. I know I could create a table inbetween but I thought I'd try there, where I'm stuck is on setting up the relation. All the documentation shows
But when I run it I get an error on the resource I'm doing the with as "There is not enough information to infer the relation"
Any suggestions?
3 Replies
You have to set up the relation on both sides
In the table that has the images you set up a
many(images)
In the images table, you set up the one(whatever_table_name_uses_images)
And try to add a relation name (the same) on both sides as well. Like
many(images, { relationName: "resources.image" })
or something like thatYeah