This first example returns all nodes of type page where the value of field_some_field (an integer field) is 14.
$query = \Drupal::entityQuery('node')
->condition('type', 'page')
->condition('field_some_field', 14);
$results = $query->execute();
This example shows that an entityQuery is built up by adding various conditions, sorts, ranges, and other qualifiers. Note that the $query methods are all chainable - each one returns the $query, so we can add multiple conditions per line.
For conditions, the default operator is "=", so in both of the conditions shown above, the EntityQuery is looking for type=page and field_some_field=14. If we wanted to find all basic page nodes where field_some_field > 14, then the entityQuery would look like this:
$query = \Drupal::entityQuery('node')
->condition('type', 'page')
->condition('field_some_field', 14, '>');
$results = $query->execute();
Sorts and ranges can also be easily added:
$query = \Drupal::entityQuery('node')
->condition('type', 'page')
->condition('field_some_field', 14, '>')
->sort('nid', ASC)
->range(0, 10);
$results = $query->execute();
Finally, we can save ourselves some typing by calling execute() directly on the $query:
$results = \Drupal::entityQuery('node')
->condition('type', 'page')
->condition('field_some_field', 14, '>')
->sort('nid', ASC)
->range(0, 10)
->execute();
The execute() method returns an array of IDs for the entities found. For node entities, this is the node ID. If this was an entityQuery of users, then the ID would be user ID.