Filter results by reference field (.contains)

Hi,

What I did was create a reference field in the collection. Each reference field has a unique ID, and you can see that ID when you change your reference field to a plain text field (it will break connections and will show an error but it will display that unique ID).

Copy that ID and paste it to the code with the .contains feature :

//searches keywords typed upon pressing 'Enter'
export function searchInput_keyPress(event, $w) {
	if (event.key === "Enter") {
	//shows a pre loader
		$w('#loader').show();
	let filter = wixData.filter();
	if ($w("#checkbox1").checked)
 	{
    	filter=filter.ne("dispo", true);
	}
	filter = filter
	//here is the ID linked to a reference in the collection
		.contains("evenement", "810fcbd1-becf-4471-8938-4a0c1afd38a0")
		//other criteria searched...
		.contains("title", $w("#searchInput").value)
		.contains("categorie", $w("#categorieInput").value)
		.contains("vendeur", $w("#vendeurInput").value)
		.contains("type", $w("#typeRadio").value);
	$w("#dynamicDataset").setFilter(filter)
	//hides loading screen after data was retrieved
	 .then( () => {       
            $w('#loader').hide();
            wixData.query("commentaires")
	  			.contains("reference", $w('#referenceText').text)
	  			.find()
		  			.then( (results) => {
						let numberOfItems = results.totalCount;
						$w('#nbrComments').text = numberOfItems + '';
					});
     });
	}
}