Imagine two Drupal 9 custom entity types named a
and b
.
Entity type a
has two fields a_f1
and a_f2
.
Entity type b
has a field b_a
which is an entity reference with a target type of a
and unlimited cardinality.
How does one create an entity query which finds all entities of type b
at least one of whose b_a
entity references points to an a
entity which has value 'v1' for its field a_f1
and value 'v2' for its field a_f2
?
It's not appropriate in this case to find a b
which has one entity reference pointing to an a
entity with a_f1
of 'v1' but a_f2
of 'something else', and another entity reference pointing to a different a
entity with a_f2
of 'v2' but a_f1
of 'wrong value'.
I could do this in my sleep with direct SQL queries, but that's frowned on in the Drupal world. I'm having a hard time finding the guidance for doing this the Drupal Way in the official Drupal documentation.
Does the Drupal entity query API support this functionality?