We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Here is a quick example of how you can define a filter function, and then use this filter function when performing a push replication.
String filesDir = getContext().getFilesDir().getAbsolutePath(); TDServer tdserver = new TDServer(filesDir); // install the filter TDDatabase database = tdserver.getDatabaseNamed("ektorp_filter_test"); database.defineFilter("evenFoo", new TDFilterBlock() { @Override public boolean filter(TDRevision revision) { Integer foo = (Integer)revision.getProperties().get("foo"); if(foo != null && foo.intValue() % 2 == 0) { return true; } return false; } }); HttpClient httpClient = new TouchDBHttpClient(tdserver); CouchDbInstance server = new StdCouchDbInstance(httpClient); // create a local database CouchDbConnector db = server.createConnector("ektorp_filter_test", true); // create 3 objects TestObject test1 = new TestObject(1, false, "ektorp-1"); TestObject test2 = new TestObject(2, false, "ektorp-2"); TestObject test3 = new TestObject(3, false, "ektorp-3"); // save these objects in the database db.create(test1); db.create(test2); db.create(test3); // push this database to the test replication server ReplicationCommand pushCommand = new ReplicationCommand.Builder() .source("ektorp_filter_test") .target("http://@10.0.2.2:5984" + "/ektorp_filter_test") .continuous(false) .filter("evenFoo") .build(); ReplicationStatus status = server.replicate(pushCommand);
Using this replication only one record will be replicated, the one where the "foo" value is 2.