Reputation: 2483
I am working in a project using CouchDB
CouchBase lite
and Android
.
I want to use a filter function so I am doing on my server end :
{
"_id": "_design/filters",
"_rev": "xxxxxxxxxxxxxxxx",
"filters": {
"master": "function(doc, req) { if(true==doc.ismaster) { return true; } else { return false; }}",
"work": "function(doc, req) { if(true!=doc.ismaster) { return true; } else { return false; }}",
"workdata": "function(doc, req){if (true==doc.ismaster){return false;}if (req.query.device_num==doc.device_num){return true;}if (doc.type=='field_order'){return true;}if (req.query.device_num=='20' || req.query.device_num=='21' || req.query.device_num=='22' || req.query.device_num=='23'){return true;}return false;}"
}
}
On Android
I am doing :
pullwork = work.createPullReplication(url);
pullwork.setAuthenticator(auth);
if (PreferenceManager.getTabletNumber() > 80 && PreferenceManager.getTabletNumber() < 90) {
pullwork.setFilter("filters/work");
}else {
pullwork.setFilter("filters/workdata");
But It does not work as I expect and I am always getting just the master replication but never the work replication or the workdata replication.
Any idea about why?
Upvotes: 1
Views: 160
Reputation: 2276
Filter functions aren't currently supported. See this section in the Couchbase Lite docs. (This was updated only a few weeks ago, so apologies if you saw an older version.)
You may also want to look at this GitHub issue. You can find more details on why it isn't supported. Essentially, right now, the CouchDB docs don't describe what's needed well enough to implement compatibility.
Upvotes: 1