I have a collection of customers with their visited places, organised as follows:
{
"customer_id": 151,
"first_name": "Nakia",
"last_name": "Boyle",
"visited_places": [
{
"country": "Liberia",
"cities": [
"Mullerside",
"East Graham"
]
},
{
"country": "Rwanda",
"cities": [
"West Kristofer",
"Effertzbury",
"Stokeston",
"South Darionfort",
"Lewisport"
]
}
]
}
I am trying to find all customers that have visited a specific city in a specific country. I've got it working like this:
FOR target IN usertable
FILTER [] != target.visited_places[* FILTER CURRENT.country == @country AND CONTAINS(CURRENT.cities, @city)]
LIMIT @limit
RETURN target
The query seems cumbersome and I am not sure if it is performant.
Is there any better way to do this in terms of readability and performance?