Didn't get all Document by sync_gateway

I added sync_gateway with my bucket . I got only those documents i added by couchbase lite using Android . I added few Document by PHP web application . I didn’t get that using sync_gateway. What would be the problem ?

do you add documents by sync_gateway,or directly by Couchbase Server?
you should add documents by sync_gateway REST API

Using couchbase PHP SDK following code

<?php $bucketName = "default"; // Connect to Couchbase Server $cluster = new CouchbaseCluster("couchbase://"); $bucket = $cluster->openBucket($bucketName); // Store a document echo "Storing u:king_arthur\n"; $result = $bucket->upsert('u:king_arthur', array( "email" => "kingarthur@couchbase.com", "interests" => array("African Swallows") )); var_dump($result); // Retrieve a document echo "Getting back u:king_arthur\n"; $result = $bucket->get("u:king_arthur"); var_dump($result->value); // Replace a document echo "Replacing u:king_arthur\n"; $doc = $result->value; array_push($doc->interests, 'PHP 7'); $bucket->replace("u:king_arthur", $doc); var_dump($result); echo "Creating primary index\n"; // Before issuing a N1QL Query, ensure that there is // is actually a primary index. try { // Do not override default name, fail if it is exists already, and wait for completion $bucket->manager()->createN1qlPrimaryIndex('', false, false); echo "Primary index has been created\n"; } catch (CouchbaseException $e) { printf("Couldn't create index. Maybe it already exists? (code: %d)\n", $e->getCode()); } // Query with parameters $query = CouchbaseN1qlQuery::fromString("SELECT * FROM `$bucketName` WHERE \$p IN interests"); $query->namedParams(array("p" => "African Swallows")); echo "Parameterized query:\n"; var_dump($query); $rows = $bucket->query($query); echo "Results:\n"; var_dump($rows) I insterted Document using this. But i didn't get this Document using sync_gateway


1 Like

Is it not possible to get Documents that added by PHP SDK ? Can you please explain ?

sync_gateway will add extra property _sync to store channel info,if you add document by CB PHP SDK,the _sync property will not be generated.

1 Like