Hi,
Couchbase 1.4.x querying is very generic when compared to 2.x,
1.4.x query builder,
let predicate = NSPredicate(format: "createdby == 'user1' AND (ANY detail.jobcode IN {'Jobcode1', 'Jobcode2’}")
let results = try? CBLQueryBuilder(database: self.database, select:[], wherePredicate: predicate, orderBy: nil).runQuery(withContext: nil)
But, In 2.x it’s different,
let DETAILS = ArrayExpression.variable("DETAILS")
let DETAILS_JOBCODES = ArrayExpression.variable("DETAILS.jobcode")
let a = [Expression.string("Jobcode1"), Expression.string("Jobcode2")]
let query = QueryBuilder
.select(SelectResult.all())
.from(DataSource.database(database!))
.where(ArrayExpression.any(DETAILS).in(Expression.property("details")).satisfies(Expression.not(DETAILS_JOBCODES.in(a))))
Because, we are using a generic code base for more than 100 queries. So, we are facing a hard time converting the above string’s to expression’s to work with the latest couchbase-lite-2.0 app.
In 1.4.x, I can change this string "createdby == 'user1' AND (ANY detail.jobcode IN {'Jobcode1', 'Jobcode2’}"
dymanically from the document and use it in queries. But, we can’t do this in 2.x.