The Sync Function is one of the fundamental components of Sync Gateway: its main responsibility is to define which user has access to which documents. In this screencast, you’ll learn how to use the public channel (also known as the ! channel) to synchronize documents to users that haven’t logged into your app yet. This feature is particularly useful when designing the on boarding journey with dynamic data that can be changed on the backend and pulled automatically when the user starts the app for the first time. We’ll consider a note taking application and explore the following:

  1. Use the public channel to insert the Getting Started note, you can think of it as the tutorial note when the user starts the app for the first time
  2. Map the note created by a registered user to a channel that is only accessible by that user
  3. Enforce write permissions with the requireUser method
  4. Test the Sync Function with curl commands

Find the code for this lesson

You can find the Sync Gateway config file below:

And the curl commands to test the Sync Function:

  1. Persist a Public Note via the Admin API
  2. User Authentication
  3. Persist a User Note


Posted by James Nocentini, Technical Writer, Mobile, Couchbase

James Nocentini is the Technical Writer in charge of the documentation for Couchbase Mobile. Previously, he worked as a Developer Advocate and before that as a front-end developer for HouseTrip. He also enjoys writing Android tutorials for in his spare time.

Leave a reply