How to insert a reference by code?

I have two collections “Project” and “Members”.
The “Members” collection have Reference field named" My Project" connecting to “Project” collection
The site member(author) can create a project and add members into it
Now I want to display a specific project with their members
The site member(author) can have multiple projects with the same or different members
I’m able to display the Project with specific members since I have the reference field “My Project”
in that way I able to filter out the members in a same project
The problem is I do it manually, adding the specific project(reference) into “My Project”(reference field inside “Members” collection

  1. Is there a way to automatically insert a reference in the reference field of a Collection?
  2. What is the data type does reference field accepts is the Primary key or the ID(system generated) of an item?
  3. How do I get the reference value and add to the Reference Field

I new with web development especially with the wix api

Hopefully, you can help me
thank you

@anthonybasang18 Have a look at these functions. It will take some trial and error, but you will get the idea of how they work.

https://www.wix.com/corvid/reference/wix-data.html#insertReference
https://www.wix.com/corvid/reference/wix-data.html#replaceReferences
https://www.wix.com/corvid/reference/wix-data.html#removeReference

I tried to read that but I still don’ t get it
But I will try to conduct some experiments