$nids = \Drupal::entityQuery('node') ->condition('type', 'article') ->condition('status', 1) ->range(0, 5) ->execute(); $nodes = \Drupal::entityTypeManager() ->getStorage('node') ->loadMultiple($nids);
$uids = \Drupal::entityQuery('user') ->condition('status', 1) ->range(0, 10) ->execute(); $users = \Drupal::entityTypeManager() ->getStorage('user') ->loadMultiple($uids);
$tids = \Drupal::entityQuery('taxonomy_term') ->condition('vid', 'tags') ->range(0, 20) ->sort('weight') ->execute(); $terms = \Drupal::entityTypeManager() ->getStorage('taxonomy_term') ->loadMultiple($tids);This code queries the database for the first 20 terms within the 'Tags' taxonomy vocabulary and loads them as fully structured taxonomy objects. In conclusion, Drupal entityQuery is a core component of the Drupal ecosystem and can be considered as part of the Drupal API. It is utilized by many contributed modules and is part of the Drupal Core package library.