How to only query objects with items in a relation

Hi,
I have a data object with a relation.

Category
- String name
- Relation materials
- Relation childCategories


I only want to query those categories that have childCategories items. I tried everything like:
WHERE childCategories.length|count|numberOfItems>0
Nothing works? Any Idea?
Thanks,
Phillip

Hi Phillip,

You can use the following whereClause:

childCategories.objectId is not null

Regards,
Mark

Awesome support! Thank you very much!

Phillip

How about if you wanted to query childCategories > 1?

Hello, @Kelly_Oglesby

To achieve your desired result of querying categories where childCategories > 1, you can retrieve all categories and programmatically filter the results. First, query for categories with related childCategories using a basic whereClause, and then filter the results based on the count of related child categories. This approach allows you to work with only those categories that meet your criteria.

Regards,
Serhiy