RN: Couchbase lite and join

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,

  1. immutable doc - once created this document should not get updated by any user
  2. 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
}
  1. 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.

  1. Groupby ‘label’ and aggregate ‘number’
    Expected output:
    label: ABC, total: 300

  2. 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:

  1. As Iam using ReactNative+Couchbase Lite 1.4 with REST API, any suggestion to implement 2nd and 3rd scenario?

  2. 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 ?

CBM 2.0 will not support React Native . Specifically, CBM 2.0 will not be supporting the REST API that enabled the RN CBL 1.4.
Support for JS based app development technologies will be evaluated post 2.0 release (CC @ssmotra)

ok, then we have to stick with Couchbase Lite 1.4 and REST API.

As Iam using ReactNative+Couchbase Lite 1.4 with REST API, any suggestion to implement 2nd and 3rd scenario?