Parents register on our website. Then they create records/items for their kids/players in a custom collection. A many-to-many relationship exists between my two collections as a parent can have multiple kids and a kid can have multiple parents. I wanted the current logged in user and the new record created to have a multi reference relationship across the two collections: PrivateMembersData (logged on user ID), Contacts (new record ID). I needed this relationship to be established in code at the time the new record was created. My code works. I struggled with this for a long time. Wanted to post incase others can benefit from the solution and would love validation that I am not missing something myself if anyone has time to review.
This is the structure of my website and the code I am working with.