populating different dates on a repeater

Anyone know how I can populate different dates on a repeater? I have used the below code and have the fields shown coming from the database BUT how do I get different dates in the other fields? There are 12 separate dates for each course.

I have all of this working without the use of the repeater but the code is very long and I’m trying to tidy things up.

let thisCourse = $w("#dynamicDataset").getCurrentItem();
    wixData.query("Courses")
    .limit(6)
    .eq("_id", thisCourse._id)
        .find()
        .then(results => {
            $w('#repeater3').data = results.items;
            $w('#repeater3').forEachItem(($w, itemData, index) => {
                $w("#date1").text = itemData.dateone;
                $w("#duration1").text = itemData.duration;
                $w("#price1").text = itemData.individaulPrice;
                });
        });

I’m also expecting to have some trouble getting the button to setItem with the corresponding data in the relevant fields due to being in a repeater. The price and duration will stay the same but the date will be different in each row, any help on this would be much appreciated.

In your Data Collection you should only have ONE field called courseDate which will be your date value for the different courses. Then you just use the code as above and set that element on the page to that items courseDate. You should not have fields in a Data Collection with like dateOne, dateTwo and so on.

If you have then create a new Data Collection that is connected to your courses Data Collection that is called CourseEvents and with a reference to the Courses Data Collection and in this one you enter the date, time, duration, price and that information that will be different for every date or could be different.

Then when you use the repeater connected you filter out the CourseEvents when you have selected the course you want to see events connected to. Easy and clean.

Hi Andreas,

Thank you for your reply. I have tried this method before and it confused me (referencing the courses data set…) I get the impression that it should be simpler than whats in my head, but I think this might be a too much for me! I currently have 12 dates per course in each fields in the Courses Data Collection for over 50 courses all of which are different dates.
I’m a member of your website wixshow, are there any tutorials on your website for something similar?