Sync new Doc from Couchbase Server to Sync Gateway

Hi all,

I am new using Couchbase Server and Sync Gatway. Could I request any experts help me to resolve the problem about new document Sync. We created new document into Couchbase Server through JAVA API as below:

	Cluster cluster = CouchbaseCluster.create("ip");
	Bucket bucket = cluster.openBucket("our bucket");
        Map<String,Object> result = new ObjectMapper().readValue(new File("D:\\TEST.JSON"), HashMap.class);          
	JsonObject json = JsonObject.from(result);
	JsonDocument doc = JsonDocument.create(pk, json);		
	JsonDocument inserted = bucket.upsert(doc);

We would like to sync the new created document to Sync Gateway for further processing. How can I achieve this purpose. Many thanks for help

Hi @rickiehui,

Unfortunately, it’s currently not possible to write documents to a Couchbase Server bucket and have them processed by Sync Gateway.

This is because the documents need to go through Sync Gateway in order to compute the access rules based on the Sync Function.

Sync Gateway has a REST API. In this tutorial, you can learn how to import documents in bulk to Sync Gateway if that helps.

It’s safe to do read operations with the Couchbase Server SDKs on the same bucket Sync Gateway is using but all write operations should go through Sync Gateway.