I have 2 collections: one that contains tournament info data, and one that contains results of those tournaments. The results collection has the tournament title as a reference field to the tournament info collection. I am trying to populate a table with the winners of all the tournaments for a certain year. I was able to query the collection to get the titles of all the tournaments I would like to be added to the table (txlist), but I am not sure how I feed those titles into the dataset for the results to get the winner of each tournament into the table.
Tournaments collection: contains the tournament info
Boaterdataset: connected to the Results collection
Here is what I have so far:
$w.onReady(function () { // Get the date from the date field of the current item $w('#dynamicDataset').onReady( () => { //get the current item in the dynamic dataset let currentItem = $w('#dynamicDataset').getCurrentItem(); const year = currentItem.season; console.log(year) //get tx list for the year wixData.query('Tournaments') .eq('season', year) .ascending('date') .find() .then((results) => { let txdata = results.items; const txlist = txdata.map(item => item.title); console.log(txlist) // Set the table to the current season winners $w('#Boaterdataset').setFilter(wixData.filter() .contains('tournament', txlist) .eq('division','Boater') .eq('place', 1) ); }) .catch((err) => { let errorMsg = err; }) }) });
I was able to figure it out. Pretty simple once I found some other examples
$w.onReady(function () { // Get the date from the date field of the current item $w('#dynamicDataset').onReady( () => { //get the current item in the dynamic dataset let currentItem = $w('#dynamicDataset').getCurrentItem(); const year = currentItem.season; //get tx list for the year wixData.query('Tournaments') .eq('season', year) .ascending('date') .find() .then((results) => { let txdata = results.items; const txlist = txdata.map(item => item.title); // Set the table to the current season winners $w('#Boaterdataset').setFilter(wixData.filter(txlist) .eq('division','Boater') .eq('place', 1) ); }) .catch((err) => { let errorMsg = err; }) }) });