How to access nested fields in wixData.filter?

I am trying to set the filter on a dataset. The collection for the data set has a reference property called origin that represents an origin airport. It references my Airport collection. The Airport collection has a code field. I am trying to filter the dataset to only show data where the origin’s code is “SLC”. How can I accomplish this? I tried the following line of code but it isn’t working.

$w ( ‘#dataset1’ ). setFilter ( wixData . filter (). eq ( “origin.code” , “SLC” ))

I think you should put the Airport dataset on the page as well (set it via the editor UI to only show 1 item).

Then:

//call it whenever you need (but only after both datasets are ready:
function filter(){
$w('#airportDataset').setFilter(wixData.filter().eq('code', 'SLC'))
.then(() => {
const originId = $w('#airportDataset').getCurrentItem()?.id;
$w('#mainDataset').setFilter(wixData.filter().eq('origin',originId))
})
}

This was super helpful and did the trick. Thanks!!