Couchbase Lite Sync with authentication

Hello @TurboRudi,

Yes. The default sync function doesn’t give the user access to the documents. So when starting the pull replication, Sync Gateway doesn’t know the grocery documents that belong to this user.

To have per-user grocery items synced, you could have the following sync function:

function(doc, oldDoc) {
  channel(doc.channels);
  access(doc.username, doc.channels);
}

Then, in the grocery documents, add the channels property, it can hold an array of channel names and the username property (in this case user1). The pull replication should then sync those documents.

James

1 Like