Open clariontools opened 7 years ago
@clariontools this plugin targets CBL 1.4. The cordova API is a blend between the higher order CBL REST API and the native implementations. I had originally created a JS wrapper around the REST API, but ran into too many limitations.
I don't have the full native API mapped. Here is a list of what is currently implemented (Cordova API / Native Call)
cbl.changesDatabase$ / hooks up to the native database change events, returns RxJS observable for consumption
cbl.changesReplication$ / hooks up to the native replication change events, returns RxJS observable
cbl.compact / native compact call
cbl.resetCallbacks / this is a clean up function specific to this plugin
cbl.info / returns the given databases document count
cbl.initDb / this opens or creates a database and registers it in an native dictionary. this function needs to be called before any other database specific api can be used.
cbl.lastSequence / get the last sequence number of a database
cbl.replicateFrom / not implemented natively yet, I don't have a need for it in my use case, feel free to build it out and submit a PR for it.
cbl.replicateTo / not implemented natively yet, I don't have a need for it in my use case, feel free to build it out and submit a PR for it.
cbl.reset / specific to this plugin, cleans up internal dictionaries, closes event listeners etc
cbl.stopReplication / stops all replications that are currently active
cbl.sync / implements two way syncing, set to continuous. continuous = true is currently hard coded, but would be simple to make a variable
cbl.allDocs$ / implements a standard allDocs query. this returns an observable that provides array batches of documents, for large databases (50-100K docs +) sending a single document at a time is not feasible due to the latency from the cordova plugin bridge. array batches are 5000 docs on iOS and 1000 on Android. iOS runs everything on a background thread, android is background multi-threaded.
cbl.get / regular native get
cbl.getDocRev / regular native doc rev
cbl.putAttachment / regular attachment to document
cbl.upsert / aggressive update-insert, will always try to become the winning revision. The write operation will continue indefinitely until it becomes the winning revision.
Since 2.0 is coming out, I don't see a need to build out the entire API for 1.x. if you need something feel free to PR it, all review/comment/merge as quickly as I can.
Thanks for the info James. I am taking a look at this right now, I agree it doesn't make sense to build out the old api with 2.0 on the horizon. I will work with what you have exposed and would be happy to make a PR depending on how far I can go with my current evaluation.
Could you clarify (maybe in the readme) which official Couchbase Lite version is this plugin based on? I know the goal is to be ready for 2.0 which is in developer builds so is this plugin on par with Couchbase Lite 1.4 at the moment?
I have used the couchbaselabs / nativescript-couchbase plugin which seems to provide an api more close to the full api of the other native platforms, but I am not sure if it (nativescript-couchbase) offers the full api provided with both the ios and android vresions? I could not use methods like createPushReplication('http://gateway:port/bucket), createPullReplication(('http://gateway:port/bucket), setContinuous(true), etc...
Could you provide a little more clarification on how this plugin fits in with the api's provided by the true native implementations? Thank you for any information you can provide.