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.