How do you set a node reference field's default value when creating a node programatically? I use this:

$values = array(
  'type' =&gt; 'competition',
  'title‎' =&gt; 'my title goes here',
);
$node = \Drupal::entityTypeManager()
  -&gt;getStorage('node')
  -&gt;create($values);


This works perfectly. But the problem is, I also have a node reference field called "field_competition_node_reference‎". But this doesnt work:

$values = array(
  'type' =&gt; 'competition',
  'title‎' =&gt; 'my title goes here',
  'field_competition_node_reference‎' =&gt; 1,
);


How would one go about doing this? The value on the object is "target_id". Maybe that's why "create()" doesnt work?
This should work :

$values = [
  'type' =&gt; 'competition',
  'title‎' =&gt; 'my title goes here',
  'field_competition_node_reference‎' =&gt; [['target_id' =&gt; 1]],
];
Node::create($values);