Import Processing
Overview
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.
Operation
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
andrequireRole
calls in the Sync Function are treated as no-ops. -
During import,
oldDoc
isnil
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.
Configuration
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 |
---|---|
scopename |
Represents the name of each scope |
collections |
Contains different collections within each scope |
collectionname |
Represents the name of each collection within a scope. |
import_filter |
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. |