Multi-Reference Repeater Filtering

Hello! I am trying to query referenced data to allow for the filtering of “Courses” and “Tutors”. These 2 collections are also connected by reference fields from Courses to Bookings/Services and Tutors to Bookings/Staff. Tutors also has a referenced field connecting back to Courses just in case. Also, the on-page dataset is connected to “Bookings/Services”.

Here is my code:

import wixData from 'wix-data'

// For full API documentation, including code examples, visit http://wix.to/94BuAAs

$w.onReady(function () {

    $w("#dataset1").onReady(() => {
        $w("#repeater1").forEachItem(($item, itemData, index) => {

 let text = itemData.description;

 let shortenedtext = text.slice(0, 125);

 if (text.length > 125) {

                $item("#text72").text = shortenedtext;

            }

        })
    })
})

export function container1_mouseIn(event) {

 let floatOptions = {
 "duration": 500,
 "delay": 0,
 "direction": "bottom"
    };

 let $item = $w.at(event.context);

    $item("#box1").show("float", floatOptions);

}

export function container1_mouseOut(event) {
 let floatOptions = {
 "duration": 500,
 "delay": 0,
 "direction": "bottom"
    };

 let $item = $w.at(event.context);

    $item("#box1").hide("float", floatOptions)
}

export function dropdown1_change(event) {

    console.log("Running query for staff name to find id")
    wixData.query("Bookings/Staff")
        .eq("name", $w("#dropdown1").value)
        .find()
        .then((results) => {

            console.log("Staff name found");

 let items = results.items[0];
 let id = items._id

            console.log("Finding staff member ID");
            console.log(id);

            console.log("Using staff id to search tutors database"))

            wixData.queryReferenced("Tutors", id, "staff")
                .find()
                .then((tutor) => {

 let allItems = tutor.items              
 
 //needs to rewrite this to allow for data gathering of multi item referenced services (courses) 

                    console.log(allItems)

                })

            $w("#dataset1").setFilter(wixData.filter()
                .contains("tutors", id) //wrong course id - personal note
                
                
                // I think this is where my issue is taking place. 

            );

            console.log("filtering complete")

        })
}