Trouble with reference field showing Master-Detail info

Following support link explains using reference fields nicely

I precisely explains showing Single Master from ‘A’ primary dataset and it’s Details from ‘B’ referenced dataset.

How can I show All Masters from ‘A’ primary dataset and it’s Details from ‘B’ referenced dataset?

Please guide.

Anupam Dubey

Someone please help on this.

Hi Anupam,
Can you please describe the scenario that you wish to achieve ?
Roi

Thanks for the response Rio,

I have two datasets ‘Profile’ and ‘Participants’, wherein ‘Profile’ dataset maintain user profile of SPOCs (Single Point Of Contact) as explained in Velo Tutorial: Building Your Own Members Area | Help Center | Wix.com. And any SPOC loged-in can register and add participants for an event in ‘Participants’ dataset .

Profile
name
spocEmail (primary field)
chapter
phone

Participants
name
email
chapter
spocEmail (referenced field)

While entering data in ‘Participants’ dataset, am also saving logged-in user’s email in a field and has made it referenced field. So, ‘Profile’ dataset is my primary dataset with spocEmail field as primary field and ‘Participants’ dataset is referenced dataset with sopcEmail as referenced field.

Now, two issues am facing:

  1. Even though am saving logged-in user’s email in ‘Participants’ dataset, but it shows ‘Reference is broken’ in database, which needs to be set manually.

  2. It works fine in repeater for showing Single SPOC from ‘Profile’ primary dataset and details of participants he registered/entered from ‘Participants’ referenced dataset (after I update referenced field manually). Precisely, it shows all participants and corresponding SPOC details using referenced filed.
    (I used CMS: About Displaying Content from Multiple Database Collections Using Reference Fields | Help Center | Wix.com)

But how can I show all SPOC details from ‘Profile’ primary dataset and corresponding details of participants registered from ‘Participants’ referenced dataset?

Hope I could explain.

Please guide

Hi,
If you wish to insert an item (one row of data in the database collection ) with a referenced field in it, you need to make sure you are adding the entire object of the item.
For example:

const itemObj = {"_id":"b52968a1-d2c8-4595-851e-b25dc11660ec","_owner":"1674dbd2-c613-4cf1-b20b-9626ee8055c7","_createdDate":"2018-02-19T09:15:27.217Z","_updatedDate":"2018-03-04T17:16:16.850Z","name":"John Doe","spocEmail":"johnDoe@gmail.com","chapter":"five","phone": 555555555};
const toInsert = {
"referencedField": itemObj,
"name": "John Doe",
"email": "johndoe@gmail.com",
"chapter" "five":
};
wixData.insert("Participants", toInsert);

For more information:

If i understand you correctly use can use wixData.query(“dbname”).include method to get all information regarding that participant.
Feel free to paste your code here.

Good luck!
Roi