https://kotlinlang.org logo
#exposed
Title
# exposed
y

Yoavya

05/05/2020, 9:28 AM
Hi, I was wondering, if I want to create a reference between one table and multiple other tables. is this possible? For example: Lets say I have an Uploads table and I want Users table to have uploads and Posts table to have uploads as well. Can this be done with exposed? I mean with the
referencedOn
and
referrersOn
functions
t

tapac

05/05/2020, 12:45 PM
What kind of relation do you want to setup? Users -> many uploads Posts -> many uploads ?
y

Yoavya

05/05/2020, 12:46 PM
yes
but referencing by just ID is not enough since the two tables ids can collide, so I was thinking of adding a type column but I can’t reference by two columns just one
t

tapac

05/05/2020, 1:04 PM
Maybe it's worth to add UserToUploads and PostToUpload tables and link them with
via
? https://github.com/JetBrains/Exposed/wiki/DAO#many-to-many-reference
y

Yoavya

05/05/2020, 1:39 PM
I can do that, but then If I want to add something else that has uploads then I will have to create a connecting table for it
t

tapac

05/05/2020, 6:02 PM
The other way is to define something like:
👍 1
5 Views