I'm new to Realm and hit a bit of a snag when it comes to implementing a polymorphic design on a React Native.
Basically, I'm trying to figure out the best way to manage different entities that can all be involved in transactions.
We have the models Transaction, Income, Wallet, and Expense. A Transaction is always from someplace to somewhere. This could be:
- Income to Wallet
- Wallet to Wallet
- Wallet to Expense
I come from Django, where I would probably implement this with polymorphism, but Realm doesn't support that.
I've looked into a few options like using exclusive foreign keys for each entity type... But it feels... wrong.
What are the recommended pattern in this case?