Best practice - CB Sync Gateway

Currently our application is 100% offline first, where the application installed in the user’s machine talks to CB Server via CB Lite and Sync Gateway.

App (local) > CB Lite (local) > CB Sync Gateway (cloud) > CB Server (cloud)

It works fine. Now we’re planning to deploy our application to the cloud also so that the group of users who’re always online can connect to the cloud via a web browser. We’re planning to connect the application deployed in the cloud directly to CB Server.

App (cloud) > CB Server (cloud)

Is this a good approach? Or should we connect the application deployed in the cloud to the CB Sync Gateway - REST apis?

App (cloud) > CB Sync Gateway (cloud) > CB Server (cloud)

Our main concern is that if we interact directly with CB Server, will those changes be captured by Sync Gateway to be synced down to CB Lite running in offline user’s machines… Please advise…

Yes. The docs will be imported to SG so long as you have it configured to do so. Not in front of an example right now, but I can get you the config if you need it.

Thanks for the reply, Hod. Please share the configuration.

Hi Dony,

Here’s a simple example. The last two lines are the important ones.

{
  "log": ["*"],
  "databases": {
    "inventory": {
      "server": "http://localhost:8091",
      "bucket": "inventory",
      "username": "Administrator",
      "password": "Password",
      "users": { "GUEST": { "disabled": false, "admin_channels": ["*"] } },
      "allow_conflicts": false,
      "revs_limit": 20,
      "enable_shared_bucket_access": true,
      "import_docs": "continuous"
    }
  }
}

Not sure what version of platform you are on. Assuming you are on Sync Gateway 1.5 and above, you can leverage shared bucket access as described in our docs. This will enable changes from CBS to be synced over to CBL.

This blog may also help

Hi. I am doing some research for a project and was wondering if I were to use Couchbase Mobile offline, would it be as simple as just turning on the sync gateway capabilities to sync with Couchbase in the cloud? I would like to provide in-app purchase to allow this capability and the user may have a large dataset by the time they decide to use the cloud syncing capabilities.

@Tim_Glenn Why don’t you start a new post instead of taking over a nearly year-old one that doesn’t seem directly related?

Sure. I can do that… but im replying based on the topic. which is “Best Practice CB Sync Gateway” and it was relative. Some people like to keep things together some like to complain about why didn’t you search for a topic… vis a vis

Yeah it’s like the “vim vs emacs” of the forum world isn’t it? But actually my secondary goal was to find out if you really meant it since your post was flagged as suspicious by the filter. On this forum we prefer to start new threads so that we can keep a conversation relevant to the original question asked. The topic here is not the best, I admit.