Get related children - KQL Plugin

I have a product that can have one case. A case can have multiple products.

Pulling the case inside a product is working fine, but now I need to query all products for a case.

This is my product.yml blueprint:

    fields:
      case:
        label: Case
        type: pages
        query: site.find('cases')
        multiple: false
        translate: false

Inside my case.yml I have not specified any relation.

How would I do this? As I have no relation specified in a case I am not sure what the best (kirby) way is to accomplish this. I found this: Filtering compendium | Kirby CMS

$page->children()->filter(function($child) use($page) {
    return $child->related()->toPages()->has($page);
});

but as I am using the KQL Plugin I am not sure how I would write this in dot-notation.

this is your issue in kql repo: Question - Get related children · Issue #26 · getkirby/kql · GitHub

TL;DR;
you can not (for now).

Long answer:
i created a few issues at the repo as well all related to the fact that kql is limited in use without being extendable but development seems to have stopped for now. kirby 3.6.0 is keeping everyone busy.

A) if you do not have public access to your kql then just remove the interceptors with a hack

B) or if you want to keep kql public this is what i did recently

  1. create a custom method in a model wrapping that filter statement
  2. create a interceptor for your model and load the class
  3. hack kql to actually use it
1 Like

I see, thanks. As this is a rather small application with just a few items and not used in public I will just create a second query and filter the results on nodeJS side. I will look into the interceptors anyway though.

Thanks for your help!