entity Query count field aggregate
<?php
$query = \Drupal::entityQuery('node')
->condition('status', NODE_PUBLISHED)
->condition('type', 'custom_type');
$and = $query->andConditionGroup();
$and->condition('custom_taxonomy', 2);
$query->condition($and);
$and = $query->andConditionGroup();
$and->condition('custom_taxonomy', 8);
$query->condition($and);
$result = $query->execute();
->range(0, 2);
$query = \Drupal::entityQuery('test_entity');
$query->notExists('field_date');
$ids=$query->execute();
$thing_id = 101;
$q = \Drupal::entityQueryAggregate('node')
->condition('type', 'group')
->condition('field_things', $thing_id)
->groupBy('nid')
->conditionAggregate('field_things', 'COUNT', 1);
$res = $q->execute();
drill down
dpm($entity->uid->entity->name->value);
dpm($entity->field_item_preview->entity->name);
the oo way
$nids = \Drupal::entityTypeManager()
->getListBuilder('node')
->getStorage()
->loadByProperties([
'type' => 'mytype',
'status' => 1,
]);