Using admin REST API on sync gateway

I think you might be confusing the two scenarios Andy was describing - one was using the Sync Gateway Admin API, and one was using a ‘super user’ created specifically for your application.

  1. When creating documents via the Admin API, it uses the Admin account, which bypasses requireUser/requireRole. So the create won’t fail based on any require statements in the sync function. The rest of the sync function (assigning channels, etc) will be processed as usual.
  2. On the other hand, if you create your own ‘super user’ and use that user to write documents through the public API, you’ll run into the problems Andy described - something like requireUser(doc.owner) will fail unless the super user happens to be doc.owner

Based on your comments, it sounds like the Admin API is the way you want to go.