Swift 5 sub document array query question

So I’m trying to query a subdocument array.

For refrence the data is like:
Tireset{

Wheels[
Wheel1{ tireID, FrontLeft},
Wheel2{ tireID, FrontRight},
Wheel3{ tireID, BackLeft},
Wheel4{ tireID, BackRight}
]

}

Hopefully my data model makes sense.
Anyways query is something like:

SELECT *
FROM bucket
WHERE type = “Tireset” AND
ANY WHEEL IN wheels SATISFIES WHEEL.tireID = “tireToFindID” END

This seems to work on the server side but when I try to translate into swift I’m getting an error. Say I setup the where as:

.where(Expression.property(“Type”).equalTo(Expression.string(“Tireset”))
.and(ArrayExpression.any(“WHEEL”).in(Expression.property(“wheels”))
.satisfies(ArrayExpression.variable(“WHEEL.tireID”).equalTo(tireToFindID)

Swift gives me the error Argument type ‘String’ does not conform to expected type ‘VariableExpressionProtocol’. This is highlighting the “WHEEL” inside the .any(). Am I supposed to force this type value? Everything I’ve found online shows people entering strings into the .any() but maybe this only worked on an older version of swift? I’m very new to couchbase/CBL so sorry for my ignorance.

Well- you cannot just translate N1QL string query into swift (at least not yet). QueryBuilder API is different - it supports SQ L like semantics for JSON but its not the same as N1Ql

So as error indicates, you must provide a variable expression.

Now, I cannot answer your specific question as the data model is unclear and its unclear what your expected results are.
But here’s an example that you should be able to refer to and apply to your use case

{
  "type": "hotel",
"reviews": [
    {
      "author": "Camila Hudson",
      "date": "2015-03-30 01:17:05 +0300",
      "ratings": {
        "Cleanliness": 4,
        "Overall": 4,
        "Service": 5,
        "Sleep Quality": 4,
        "Value": 4
      }
    },
    {
      "author": "Lexie Wiegand V",
      "date": "2013-09-03 04:58:50 +0300",
      "ratings": {
        "Cleanliness": 4,
        "Location": 5,
        "Overall": 5,
        "Rooms": 5,
        "Service": 5,
        "Sleep Quality": 5,
        "Value": 4
      }
    }
  ]
}

If you want to get a list of documents where overall rating is less than 4, then your query will look like this

   let VAR_OVERALL = ArrayExpression.variable("review.ratings.Overall")
    let VAR_REVIEWS = ArrayExpression.variable("review")
    let searchQuery = QueryBuilder
        .select(SelectResult.expression(Meta.id),
                SelectResult.expression(Expression.property("name")))
        .from(DataSource.database(db))
        .where(Expression.property("type").equalTo(Expression.string("hotel"))
            .and(ArrayExpression.any(VAR_REVIEWS).in(Expression.property("reviews"))
                .satisfies(VAR_OVERALL.lessThan(Expression.int(4)))))
        .limit(Expression.int(limit))

You should be able to map this to your query

Can you point to specific references where you saw this?

Here are an Xcode playground that should help you get started. All the examples in the playground are used in following blogs