I need to select some entities that have a certain field (user reference) empty or that field does not contain the current user as a reference.
I tried this. It works fine if the field is empty or if the field contains exactly one value. For multiple values, it displays the wrong value.
$query = $this->entityTypeManager()
->getStorage('my_entity_type')->getQuery();
$group = $query->orConditionGroup()
->notExists("my_field")
->condition("my_field", \Drupal::currentUser()->id(), "<>");
$query->condition($group);
$query->condition("type", "my_bundle_id");
What changes should I do to my code to make it work with a multi-value field?