I built a Hybrid mobile app using couchbase lite and Cloudant. The iOS version of the app works great however the android version is not returning any results from the queried views.
So far from troubleshooting these are what I’ve found out:
Replication was successfully between with couchbase lite and Cloudant
in both directions
The /{db}/_all_docs REST API works perfectly
The /{db}/{doc} REST API get document by Id also works properly
The design documents were successfully replicated to the local
database and I was able to retrieve a design document via the
/{db}/{design-doc-id} REST API
The strange thing is that the “total_rows” equals to 0 as shown below:
Even when I created a new design document similar to the above and then insert a document the result of the view still has a “total_rows” set to 0 however in cloudant the result is not empty.
@eforth Did you ever figure out this issue? I am facing the same.
@ldoguin I am also having an issue where views work perfectly on IOS, but not Android.
I confirmed that data replication had happened between the server and cblite.
I created views: const views = { returnAll: { map: function(doc) { emit(doc); }.toString() } }; database.createDesignDocument('_design/voters25', views);
I confirmed that the views had been created with a: database.getDesignDocument('_design/voters25').then((result) => {console.log(result)});
However, when I search for the actual view data, I receive an empty array: database.queryView('_design/voters25', 'returnAll').then((result) => {console.log(result)});
This is using an object (dictionary, map…) as a key. We don’t recommend doing that, because the keys of the object don’t have a defined ordering, so the sort order will be implementation-dependent. You should use an array instead for a compound key, with the primary key as the first object.
Thanks for the input, we’ll implement this change on our end. This is actually just an example, we are seeing the same issue when using the following as a test:
emit(doc) has the same problem, of course, because doc is also an object. (And it doesn’t make any sense, because there’s no indication of how the docs should be sorted.)
@chris.duflo,
Additional comment. emit(key) without value parameter does not work with CBL Android. With emit(key), value is passed as undefined. CBL Android can not understand it. The value parameter of emit(key, value) is always required.