Try to understand the difference between Database and Bucket from sync gateway perspective

I can create a json document via sync gateway via the REST API call

curl -X POST “http://localhost:4984/mydb/” -H “accept: application/json” -H “Content-Type: application/json” -H “Authorization: Basic ENCODED_AUTH” -d “{"data":"My Content"}”

the command returned
{“id”:“4ef823d4b6f706e1ad4a900ec1ff51ab”,“ok”:true,“rev”:“1-21c3fa97d6140d81e9a66c0a536ffa36”}

and I am able to get the data by the “id”
curl -X GET “http://localhost:4984/mydb/21c3fa97d6140d81e9a66c0a536ffa36” -H “accept: application/json” -H “Authorization: Basic ENCODED_AUTH”

it’s all working, however it’s confusing to me that the keyspace in REST API does not require Bucket name, so how can I find the new document in CB Server?
I also run
http://localhost:4985/mydb/_replicationStatus?includeConfig=true
the config returned don’t have any information regarding bucket.

Is it a correct understanding that sync gateway pass the JSON data to CB server, then CB server decide the “default” bucket to hold the data, or is there any specific config that I haven’t discovered that can push the JSON document to a bucket?

Currently I can only verify the data exist by running the “GET” curl command, but can’t find that JSON file anywhere in the CB server

The bucket Sync Gateway uses is explicitly associated with a database. This is determined when the database is created, but can be seen with the GET /db/_config?include_runtime=true endpoint, which will show you the full configuration, including any default or inferred values.

You are correct that Sync Gateway uses Couchbase Server and the bucket configured for the database as its only storage mechanism.

2 Likes

Thanks ! Yes that’s really helpful I can find the bucket and the data.
Is there an endpoint or extra parameters to return the CB server info?

http://sg:4985/_config?include_runtime=true will return the full Sync Gateway runtime configuration - including which server you’re bootstrapped against, and all of the databases.

1 Like

yea that endpoint provides quite enough info !

I didn’t think that remove database in the path can provide this info

Thanks again we can close this thread !