Allow members to connect with other members

Basically we have members through the wix member area. We then allow members to create contacts. Then members will be able to add other contacts to their profile so they can only view those specific contacts. I tried using references between the members dataset and the contacts dataset to store which contacts each member has added.

Here is the contacts dataset, I have only used references a couple of times and don’t even know if this will work for what we need. I added the MyContacts to show which contacts are added to that person, and then the Member Owner to show which member made that contact.


Do we need to make a custom member database away from the pregenerated wix one in order to reference correctly?

Also here is the code I used to try to only display the contacts that the member added in a repeater. This code could not be working because of the way the references are setup or because this code is not written correctly.

import wixUsers from 'wix-users';
import wixData from 'wix-data';

$w. onReady(async function () {
 let user = wixUser. currentUsers
 let userId = user. Id;
 let isLoggedIn = user. loggedIn;
 let userEmail = user. getEmail()
console.log(userId, userEmail)

wixData. query('Members/PrivateMembersData')
        .eq("loginEmail", userEmail)
        .find()
        .then( (results) => {
 let firstItem = results. item[0];
        $w("#dataset1"). setFilter( wixData. filter()
            .eq("ownerMember", "userEmail")
)
 
        })
 
    .catch( (err) => {
 let errorMsg = err;
    })
 
})
 
 

please let me know if I am headed in the right direction on this or If I need to
do something else to make this work.