$nids = \Drupal::entityQuery('node')
->condition('type', 'my_custom_type')
->execute();
$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);
$connection = \Drupal::database();
$query = $connection->query("SELECT * FROM {node} n WHERE type > :type", [
':type' => 'article',
]);
$result = $query->fetchAll();
foreach ($result as $item) {
$node = \Drupal\node\Entity\Node::load($item->nid);
//dpm($node);
$title = $node->get('title')->getValue();
$title = $title[0]['value']);
$database = \Drupal::database();