This repository is originaly fork from happio/cordova-plugin-couchbase-lite which provides a standard cordova API used for couchbase-mobile version 1.4.1 (also, with small modification, it can be used for couchbase-mobile version 1.5).
With release of couchbase-lite mobile version 2.0, several native classes are updated (more information) (It also can be safe to say it is almost rewritten of previous version). New query system, indexing, full-text search, on-device replicas and eventing capabilities are the new features implemented in the latest version.
Integrating with ionic 3, now you can use WKWebView.
It is not fully implementations of couchbase-lite funcionalities. There are more to come. (needles to say, use it at your own risk ;) )
First add the plugin to your project by
cordova add plugin https://github.com/makbari/cordova-plugin-couchbase-lite-2.0.git
Add RxJs inside Index.html Version 5.5.2(download the file and add it inside your asset folder).
<script src="assets/rx.js"></script>I try to compose a simple todo application with ionic 3, and place it in this repo.
Params: [dbId:string]
Returns: Promise -> string
Get a document from the database
Params: [dbId:string, docId:string]
Returns: Promise -> Doc
Params: [doc, isLocal: boolean = false]
Returns: Promise -> string
Returns all documents in the database in array batches.
Params: [dbId:string]
Returns: Observable -> [docs...]
Starts continuous push and pull replication against a database
Params: [dbId:string, syncUrl:string, user:string, pass:string]
Returns: Promise -> boolean
Create or update a document. always makes itself the winning revision.
Params: [dbId:string, docId:string, jsonString:string, isLocal:string ("local" || "normal")]
Returns: Promise -> string
Starts a never ending (until reset is called) stream of database changes
Params: [dbId:string]
Returns: Observable -> {docId:string, is_delete:bool, seq_num:number}
Starts a never ending (until reset is called) stream of replication changes
Params: [dbId:string]
Returns: Observable -> 'string status'
Stops all replications.
Params: []
Returns: Promise -> boolean
Gets the current sequence number of the given database
Params: [dbId:string]
Returns: Promise -> number
Gets the doc count of a local database
Params: [dbId:string]
Returns: Promise -> number
Runs database compaction
Params: [dbId:string]
Returns: Promise -> string
Removes all the database instances from the native array, cancels all change listeners on databases and replications.
Params: []
Returns: Promise -> boolean
Gets the current revision of a document
Params: [dbId:string, docId:string]
Returns: Promise -> string
Adds an attachment to a document. the directory path of the file is relative to the files folder on android or the root of the app sandbox on ios.
Params: [dbId:string, docId:string, fileName:string, attachmentName:string, mimeType:string, dirPath:string ]
Returns: Promise -> number
Your Help in developing plugin wrapper (ionic) for the andriod and implementing other functionalities is much appreciated.
Couchbase Lite Cordova plugin that provides a standard cordova interface instead of relying on the built in REST Server or another HTTP API layer. The native implementations run on their own background thread(iOS)/threads(android) so operations will never block the UI. This repo is intentionally not forked from the main couchbase-lite-phonegap repo. A seperate issue tracker is needed to track issues and progress with the cordova interface code. This repo does not intend to provide improvements ahead of the main repository for the native code. This code will be manually updated as it is released from couchbase.
The native API was developed partially out of performance concerns with the REST server and also in preparation for Couchbase Lite 2.
This project depends on RxJS 5.x, lodash and an A+ compliant Promise library to be globally available in the implementing project.