thinky icon indicating copy to clipboard operation
thinky copied to clipboard

Polymorphic Associations?

Open ghost opened this issue 10 years ago • 1 comments

I am new to thinky and have searched for an answer to this question with no luck. I apologize if there is an obvious way to accomplish what I need and I am missing it.

I am building an application that will have many polymorphic associations in the data model. For example a URL table will exist that can be related to a citizen, campaign or organization tables. Because of searching patterns I would not want to embed the URL into the other tables. I would like to store two fields in the URL table describing the relation. One with the id, the other the type. For example UrlableId: 8279c4c8-67ae-4031-ac3f-303b36f2e8dd, UrlableType:citizen and when I search the URL table I am able to use the belongsTo relationship to return the correctly associated table model. When I write the belongsTo relationship instead of a single object model I could enter an array of object models.

This is how it is done in rails. http://guides.rubyonrails.org/association_basics.html#polymorphic-associations

Any help with how I could accomplish this would be greatly appreciated.

ghost avatar Oct 12 '15 17:10 ghost

Sorry I missed this issue in my emails.

If I read properly the definition of polymorphic associations, these are currently not available. Slightly related to #362 too

neumino avatar Oct 19 '15 02:10 neumino