Export Import

← Back Database segment

Description

A database segment is a part of the full database (vertical or/and horizontal), similar to those created by the SaveLoad addon. You can use segment files to transfer or exchange data. For example, a database segment can be used with Unity Remote config to update databases on player devices. The following formats are supported: binary (most compact), JSON-row-based (good readability, big memory consumption) and JSON-field-based (average readability, less memory consumption) To create a database segment use "Segment" data source and job.

Which parts are included is defined by merge settings. To merge a database segment with the default repository, use the following code (modify settings if needed)

Example code (binary format)
    var databasePart = new BGRepo(File.ReadAllBytes(filePath));
    BGRepo.I.Merge(databasePart, new BGMergeSettingsEntity
    {
        AddMissing = true,
        RemoveOrphaned = true,
        UpdateMatching = true,
    });
    
Example code (JSON format)
    var databasePart = new BGRepo(File.ReadAllText(filePath, Encoding.UTF8));
        BGRepo.I.Merge(
            databasePart,
            new BGMergeSettingsEntity
            {
                AddMissing = true,
                UpdateMatching = true,
                RemoveOrphaned = true,
            }
        );
    
← Back to Export Import