Skip to Content
May 08, 2022 at 01:28 PM

CAP Filter composition by field



I have a parent entity with an items composition. What is the best way to create a service entity/view, which returns the parents with their items, where the items are filtered by one of their fields?

I'm looking for something like this:

entity Parent as projection on model.Parent { ID, name, items[type_code = '10'] }

I think I could do it with the .on('READ') handler, but it needs to work generally with all odata queries which includes the items, so for example /Parent(x)/items and /Parent?$expand=* should all be filtered.

Thanks, Zsolt