mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
ImportableUniqueObjects and to-many relationship #366
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Maxtws on GitHub (Jun 23, 2021).
Hi!
I have 10 unique objects (Category) stored in database. Is it possible to link some of them to multiple entities? Here're my entities:
And the other entity that has to-many reference on Category:
By the time I create Post object, all 10 Category objects are already persisted in DB.
ImportSource for the Post entity has only list of category IDs. So I fetch category entities from DB and assign them to
categorieslike this indidInsert(...)method in Post class:However, while printing all posts I can only see some of them have
categoriesfilled. In fact I can see only unique Category objects appear in print.How do I set up my entities relationships to be able to have many categories in
categoriesand have only 10 unique Category objects?@Maxtws commented on GitHub (Jun 25, 2021):
It seems like this might be similar to https://github.com/JohnEstropia/CoreStore/issues/229
However I'm not sure I understand this solution: "relationships should have the inverse relationship set on both entities"?