Data Sync Locally on Device

      +

      Description — Couchbase Lite Database Sync - Synchronize changes between databases on the same device

      Description — Couchbase Lite Database Sync - Synchronize changes between databases on the same device
      Related Content — Remote Sync Gateway | Peer-to-Peer Sync

      Overview

      Couchbase Lite supports replication between two local databases at the database, scope, or collection level. This allows a Couchbase Lite replicator to store data on secondary storage. It is useful in scenarios when a user’s device is damaged and its data is moved to a different device.

      Example 1. Replication between Local Databases
      CBLDatabaseEndpoint *targetDatabase = [[CBLDatabaseEndpoint alloc] initWithDatabase:self.otherDB];
      CBLReplicatorConfiguration *replConfig = [[CBLReplicatorConfiguration alloc] initWithTarget:targetDatabase];
      replConfig.replicatorType = kCBLReplicatorTypePush;
      
      NSError* error = nil;
      CBLCollection *collection = [database collectionWithName:@"collection1" scope:@"scope1" error:&error];
      [replConfig addCollection:collection config:nil];
      
      self.replicator = [[CBLReplicator alloc] initWithConfig:replConfig];
      [self.replicator start];