ios - NSPredicate complex query -


i've got complex nspredicate problem cannot solve.

my data structure follows:

category - has many titles

title - has many products

title - has latestproduct property (title.latestproduct)

titles can excluded via excluded property (title.excluded = yes) products can excluded via excluded property (product.excluded = yes)

the result looking for: need fetch list of categories in system, want exclude categories where:

  • all category titles excluded (category.titles.excluded == yes)

or

  • all latest products excluded (category.titles.latestproduct.excluded == yes)

or (and tough part me)

  • the sum of count of (category.titles.excluded == yes) , count of (category.titles.latestproduct.excluded == yes) equal count of category titles (category.titles.count)

i can describe problem in plain english cannot work out proper way format predicate. appreciated thanks!

so worked out way using combination of clause subquery. predicate follows:

any producttitles.excluded == nil && subquery(producttitles, $x, subquery($x.products, $y, $y.excluded == nil).@count != 0 ).@count != 0 

i think subquery how "any" clause works anyway not figure out how clause subquery of subquery.


Comments

Popular posts from this blog

Unable to open serial port using Putty to bluetooth device on windows 7 64 bit -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -