Hi, I’m using couchbase lite 2.0 for android, and I would like to query the database with n1ql queries as text, similar to what the java SDK permits mee to do:
N1qlQuery query = N1qlQuery.simple(statement);
At the moment I don’t see that possibility. Am I missing something or is this on the roadmap?
That’s not supported. Both because it would require reimplementing the N1QL parser, and to make the product more supportable — because the type-checked API eliminates lots of N1QL syntax errors and other mistakes (which often result in support tickets from customers.)
Any update on this? Even if we want to use couchbase lite with Kotlin multiplatform ( KMM). string based queries will be very usefull to share the code. otherwise all queries will need be to rewritten in Android ans iOS which should not be the case. And anyway under the hood couchbase anyway uses json to query. so if u can just expose the Query API which can execute from json directly it will be great and probably would not be very big effort.
The bad news is this API isn’t in the upcoming 2.7 release.
The good news is that it’s in Couchbase Lite For C, a version of CBL with a cross-platform pure C API. Instead of porting the entire 2.x query API to C, which would have been a very big task and awkward to use without OOP, it lets you use either the JSON syntax or [a subset of] N1QL.
The not-quite-so-good news is that CBL-C is not yet an official product, although we’ve had a lot of interest from customers. So it’s not finished yet and we don’t provide full support. Plus, of course, the C (and C++) API isn’t as easy to use in Android or iOS apps as Java/Swift/Obj-C are. But it ought to work pretty well for implementing a React or Cordova plugin…