Reputation: 3759
I have two entities Offers and Categories which are connected via a many - to - many relationship.
In the entity Offers there is a boolean attribute called played and hasCategories which is the relationship with Categories.
Also in the entity Categories there is a boolean attribute called following.
I want to fetch all Offers which played = true and all its categories has following = true
How can I do this ?
Upvotes: 0
Views: 165
Reputation: 540065
Something like this should work:
NSPredicate(format:"played = TRUE AND SUBQUERY(hasCategories, $c, $c.following = FALSE).@count = 0")
The subquery checks that none of the related categories has following == false
.
Upvotes: 3