Import Processing



      The import process is a key part of mobile convergence. It is the means by which sync gateway becomes aware of non-sync gateway data changes and obtains the mobile metadata it requires to replicate changes.

      shared bucket access


      Any non-sync gateway change is eligible for import. For more information, refer to the Sync Function documentation.

      The document is first run through the Sync Function to compute read security and routing, with the following differences:

      • The import is processed with an admin user context in the Sync Function, similar to writes made through the sync gateway Admin API. This means that requireAccess, requireUser and requireRole calls in the Sync Function are treated as no-ops.

      • During import, oldDoc is nil when the Sync Function is executed.

      You can specify a filter function dynamically using /{keyspace}/_config/import_filter, or you can define one when you set up a database. Refer to the Import Filter Configuration documentation for more information.

      Use the logging-console-log-keys in the Bootstrap Schema log key to troubleshoot import processing issues in the logs.

      Function Provision

      Use the Database Configuration Admin Rest API endpoint POST /{db}/_config to provision an import filter for a database using the application/javascript mime type.

      If you are using legacy configuration then, you need to include it in your configuration file, see: import-filter.


      You need Couchbase Lite 3.1+ and Sync Gateway 3.1+ to use custom Scopes and Collections.
      If you’re using Capella App Services or Sync Gateway releases that are older than version 3.1, you won’t be able to access custom Scopes and Collections. To use Couchbase Lite 3.1+ with these older versions, you can use the default Collection as a backup option.

      The configuration settings described here are provisioned through the Database Configuration endpoints.

        scopes: {
            {scopename...}: {
               collections: {
                  {collectionname...}: {
                     import_filter: "function(doc) { if (doc.type != 'mobile') { return false; } return true; }",
         // other configuration

      For more information, see Sync Gateway Configuration Schema.

      Property Description


      Represents the name of each scope


      Contains different collections within each scope


      Represents the name of each collection within a scope.


      Used to decide if a document should be imported. It checks the type property of the document. If it is not 'mobile', the function returns false, otherwise, it returns true.