我沒有從本地couchbase服務器同步到我的android和IOS應用程序,並且它適用於移動到服務器和服務器到移動。然後我試圖從JAVA Web應用程序插入文件到本地服務器,我成功地做到了這一點。但問題是由java web應用程序插入的文檔不能與ios/android移動應用程序同步。我的Java代碼中插入文檔到本地服務器如下:從java代碼添加文檔不同步與couchbase精簡版
public class CouchBase {
public static void main(String args[]) {
Cluster cluster = CouchbaseCluster.create("127.0.0.1");
Bucket bucket = cluster.openBucket("test");
JsonObject user = JsonObject.empty()
.put("name", "amol")
.put("city", "mumbai");
JsonDocument doc = JsonDocument.create("102", user);
bucket.insert(doc);
System.out.println(doc.content().getString("name"));
}
}
在這種代碼我已創建了一個桶,然後我已創建了一個JSON對象保持所需的值並通過該對象的JSON文檔和最後插入該文件放入桶中。現在
我的手機端代碼來創建文檔:
Document document = database.getDocument(etId.getText().toString());
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", etName.getText().toString());
map.put("city", etCity.getText().toString());
try {
document.putProperties(map);
} catch (CouchbaseLiteException e) {
Log.e(TAG, "Error putting", e);
}
在這段代碼我只是創建一個文件,並把值了。
我同步代碼如下:
Replication pullReplication = database.createPullReplication(syncUrl);
Replication pushReplication = database.createPushReplication(syncUrl);
pullReplication.setContinuous(true);
pushReplication.setContinuous(true);
pullReplication.start();
pushReplication.start();
我哪裏做的雙向同步。 我沒有得到我錯在哪裏用java code.please幫我解決了這個問題
但我看到的鏈接,我將從服務器得到什麼響應,但我沒有找到任何代碼如何使用REST API的couchbase sync_gateway.can你給我提供一些示例代碼嗎? –
按照這個鏈接,並通過api http://stackoverflow.com/questions/34200298/androidhow-to-use-couchbase-rest-api-in-android-application/34204010#34204010 –
所以我們需要從哪一方從網站或從android/ios應用程序調用couchbase sync_gateway的REST API? –