Craft 3 plugin - how to update entry with field of Entries type Using PHP, I want to update a field of Entries type of an existing entry.

Fields of type Text and Number will update with the following code:

$entry = Entry::find()-&gt;id($entryId)-&gt;one();
$entry-&gt;textField = 20; // works
$entry-&gt;entriesField = Entry::find()-&gt;id($relatedEntryIds)-&gt;all(); // doesn't work
Craft::$app-&gt;elements-&gt;saveElement($entry);


I looked into the source code and it seems to be expecting a craft\elements\db\EntryQuery object but I can't get it to work.

Can anyone please help?
Ok this was easy.  Tried it at first but didn't work and was successful after another go.  All it needed was a array of Entry IDs.

Working code:

$entry = Entry::find()-&gt;id($entryId)-&gt;one();
$entry-&gt;textField = 20; // works
$entry-&gt;entriesField = [$relatedEntryId1, $relatedEntryId2]; // works
Craft::$app-&gt;elements-&gt;saveElement($entry);