ReactNative+ react-native-couchbase-lite library (supports Couchbase Lite 1.4 with REST API)
When I started couchbase lite with single document type, I didn’t face much difficulties, but when the application grows more and more complex, i had VERY tough time.
I have two set of document as,
- immutable doc - once created this document should not get updated by any user
- mutable doc - this is the child document of immutable doc, where user can update it (like comments, label etc)
First set record:
immutableDoc_id1:{
type: immutable,
name: XYZ,
number: 200
}
mutableDoc_id1:{
type: mutable,
immutableDoc_id: immutableDoc_id1,
label: ABC
}
Second set record:
immutableDoc_id2:{
type: immutable,
name: XYZ,
number: 100
}
mutableDoc_id2:{
type: mutable,
immutableDoc_id: immutableDoc_id2,
label: ABC
}
-
Groupby ‘name’ and aggregate ‘number’, this is quite easy to implement as,
a. emit(name, number); + reduce to return aggregate number value
b.return manager.query.get_db_design_ddoc_view_view({ db: DB_NAME, ddoc: 'main', view: 'groupby_name', include_docs: false, group:true, group_level: 1, reduce:true, }).then(res => { return res; });
output:
name: XYZ, total: 300
But it is VERY hard time for me to implement the following scenario, by joining two documents. I tried pseudo join but it didn’t help.
-
Groupby ‘label’ and aggregate ‘number’
Expected output:
label: ABC, total: 300 -
Filter by ‘label’ to display in list view and sortby ‘number’
Expected output:
Record1 - name: XYZ, label: ABC, number: 100
Record2 - name: XYZ, label: ABC, number: 200
…
Queries:
-
As Iam using ReactNative+Couchbase Lite 1.4 with REST API, any suggestion to implement 2nd and 3rd scenario?
-
It looks N1QL support in Couchbase Lite 2.0 has more flexibility in joining two documents. Updating reactnative-couchbase-lite plugin to support Couchbase Lite 2.0 will help RN users to play with joining documents without much difficulties. Does reactnative-couchbase-lite will be updated to support Couchbase Lite 2.0 ?