Ash FrameworkAF
Ash Framework3y ago
6 replies
Terryble

How to do polymorphic relationships, but with only 1 table?

Apologies if this has been answered before, but I couldn't find it in the search function.

I want to create a table called transactions with the following columns:

transactions
------------
source_id
source_type
amount
destination_id
destination_type


I know there is documentation regarding polymorphic resources in Ash, but it uses multiple tables to create the relationship.

My intention with the transactions table is to be able to do various combinations of source_type and destination_type, so I don't think having multiple tables is a good solution.

How can I do this in Ash?
Was this page helpful?