Search the item content of a reference field

I would love to find out that it is possible to query / search a database, and also search within the fields of a reference field.
For example if I have a list of cities that have a reference field to the list of countries and in the table of countries let’s say there is a field of the number of people living in the whole country, I want to query the list of cities, which will bring me all cities with over 10 million inhabitants.
For example something like this, is there a proper way?

wixData.query("cities").include("countries")
   .ge("countries.residents", $w('#input41').value)).find()

I don’t think that’s possible.
You should retrieve the all cities and filter using the JS .filter method.

I’m not sure , but since it’s a single reference field I would have suggested exactly the code you have there. That didn’t work?