Import Data

Imports documents from file to a game data.

Command

# local game data (windows)
dnx dotnet-charon -- DATA IMPORT \
  --dataBase "c:\my app\gamedata.json" \
  --schemas Character \
  --input "c:\my app\characters.json" \
  --inputFormat json \
  --mode safeUpdate

# remote game data
dnx dotnet-charon -- DATA IMPORT \
  --dataBase "https://charon.live/view/data/My_Game/develop/" \
  --schemas Character \
  --input "./characters.json" \
  --inputFormat json \
  --mode safeUpdate \
  --credentials "<API-Key>"

Parameters

--dataBase

Absolute or relative path to game data. Use quotation marks if your path contains spaces.

# local file
--dataBase "c:\my app\gamedata.json"

# remote server
--dataBase "https://charon.live/view/data/My_Game/develop/"
--credentials

The API key used to access remote server in case of –dataBase being URL.

--schemas

A list of types of documents (schemas) to import. By default all schemas EXCEPT metadata are imported.

  • Use space to separate multiple schemas.

  • You can use wildcards (*) at the beginning and end of names.

  • You can use identifiers in {} instead of names.

  • You can exclude certain names by using an exclamation mark (!) at the beginning of their names.

# schema name
--schemas Character
--schemas Character Item

# all (default)
--schemas *

# masks
--schemas Char*
--schemas *Modifier
--schemas *Mod*

# schema id
--schemas {18d4bf318f3c49688087dbed}

# negation
--schemas Char* !Character
--schemas !*Item*

# excluding system schemas (Schema, SchemaProperty, ProjectSettings)
--schemas ![system]
--mode

Import mode controls merge behavior during import.

# (default)
--mode createAndUpdate

--mode create
--mode update
--mode safeUpdate
--mode replace
--mode delete
createAndUpdate

creates new documents and updates existing ones

create

only creates new documents, existing documents are kept unchanged

update

only updates existing documents, no new ones are created

safeUpdate

same as update but without creating, moving and erasing embedded documents

replace

replaces the entire collection with the imported documents

delete

deletes documents found in the imported data

--validationOptions

List of validation checks and repairs to perform during import. Defaults to repair repairRequiredWithDefaults deduplicateIds resolveConflictingUnions - repairs only, with no integrity checks. Pass the check* flags explicitly to have the import verify the data, and see Validation for what each flag does.

# no checks
--validationOptions none

# all repairs
--validationOptions repair

# deduplicate documents with the same Id
--validationOptions repair deduplicateIds

# fill required fields that have a default value
--validationOptions repair repairRequiredWithDefaults

# erase values whose type does not match the property's data type
--validationOptions repair eraseInvalidValues

# fix malformed Union values:
#   empty union (no variant set)      → erased to null
#   conflicting union (2+ variants)   → last variant in schema order is kept
--validationOptions repair resolveConflictingUnions

# integrity checks - applied only when requested
--validationOptions checkTranslations
--validationOptions checkRequirements
--validationOptions checkFormat
--validationOptions checkUniqueness
--validationOptions checkReferences
--validationOptions checkSpecification
--validationOptions checkConstraints
--input

Path to a data file. Alternatively, you can use Standard Input or URL.

# standard input (default)
--input in
--input con

# absolute path (windows)
--input "c:\my app\characters.json"

# absolute path (unix)
--input "/user/data/characters.json"

# relative path (universal)
--input "./characters.json"

# remote location (HTTP)
--input "http://example.com/characters.json"

# remote location with authentication (FTP)
--input "ftp://user:password@example.com/characters.json"
--inputFormat

Format of imported data.

# Auto-detect by extension (default)
--inputFormat auto

# JSON
--inputFormat json

# BSON
--inputFormat bson

# Message Pack
--inputFormat msgpack

# XML (removed in 2025.1.1)
--inputFormat xml

# XLSX Spreadsheet
--inputFormat xlsx
--inputFormattingOptions

Additional options for specified format.

--output

Optional path to a import report file. If the file exists, it will be overwritten. The directory must already exist. Alternatively, you can output to Standard Error, Standard Output, /dev/null, or a URL.

# standard output
--output out
--output con

# standard error
--output err

# null device (default)
--output null

# absolute path (windows)
--output "c:\my app\document.json"

# absolute path (unix)
--output /user/data/document.json

# relative path (universal)
--output "./document.json"

# remote location (HTTP)
--output "http://example.com/document.json"

# remote location with authentication (FTP)
--output "ftp://user:password@example.com/document.json"
--outputFormat

Format of import report.

# JSON (default)
--outputFormat json

# BSON
--outputFormat bson

# Message Pack
--outputFormat msgpack

# XLSX Spreadsheet
--outputFormat xlsx
--outputFormattingOptions

Additional options for specified format.

--dryRun

Allows you to run the command without actually making any changes to the game data, providing a preview of what would happen.

This command supports universal parameters.

Input Data Structure

The data you input should follow this structure (recommended):

{
  "Collections": {
    "<Schema-Name>": [
      {
        // <Document>
      }
    ]
  }
}

This structure is also accepted:

{
  "<Schema-Name>": [
    {
      // <Document>
    }
  ]
}

A list of documents is accepted if only one name in --schemas is specified:

[
  {
    // <Document>
  }
]

And single document is accepted too if only one name in --schemas is specified:

{
  // <Document>
}

See also