-
-
Notifications
You must be signed in to change notification settings - Fork 254
Description
Hello, how about make many-to-many more flexible by support some more customizing tags?
| return fmt.Sprintf("id in (%s)", subQuery), []interface{}{modelIDValue} |
I have some tables for example stores and table consumers, which is related each others as many to many. But in some reason, consumers has field card_id and mapping table for this relationship should be connected by table cards_stores or transactions, using card_id and store_id.
In this case, if I can override keys id to card_id and/or consumer_id to card_id, it is possible that I make relationship between this two models directly. (without make model card and two step relationships)
for example,
SELECT name FROM stores WHERE id IN (
SELECT store_id FROM cards_stores WHERE card_id = "0000-0000-0000-0000"
)
If I can override modelColumnID like columnFieldID, or
SELECT name FROM consumers WHERE card_id IN (
SELECT card_id FROM cards_stores WHERE store_id = "000-00-000000"
)
If I can override id in the code reference above.
How do you think about this idea? If you feel good, I will try to make a PR for it.
For the more, In my opinion, we can consider about custom raw query per the relationship. It will be helpful for more cases.