mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Fetching fetch all categories where all items or sub_categories items are "veg" #333
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 @techiesanjaypathak on GitHub (Jun 11, 2020).
My restaurant table structure is as follows:
MenuCategory
restaurant_id
category_id
category_name
items
sub_categories
MenuSubCategory
ranking
sub_category_id
sub_caterory_name
MenuItem
item_id
item_name
item_price
item_type <------- Can be "veg" or "non-veg"
Currently, I am fetching all the categories for a particular restaurant like this:
CoreStoreDefaults.dataStack.fetchAll(
From()
.where(format:"%K = %@", #keyPath(MenuCategory.restaurant_id), restaurant_id)
.orderBy(.ascending(.category_id))
)
And accessing subCategories by category?[section].sub_categories
and accessing items category?[section].items
How to fetch all categories where all items or sub_categories items are "veg"?
@JohnEstropia commented on GitHub (Jun 12, 2020):
There is no built-in syntax in CoreStore for this yet, but you can use SUBQUERY expressions in the
where()clause