Skip to main content

Data Import/Export

📥 Collection Management Import

CloudBase supports batch data import, helping you quickly migrate existing data or initialize test data.

🚀 Operation Procedure

  1. Access the console: Go to the CloudBase console
  2. Select collection: Switch to the Collection Management Page and select the target collection
  3. Start Import: Click the "Import" button (supports JSON and CSV formats)
  4. Configure Import: Select file format and conflict resolution mode
  5. Execute Import: Click "Import" to start the data import process.

⚙️ Conflict Resolution Mode

ModeBehaviorApplicable ScenariosNotes
InsertAlways inserts new recordsInitial data importDuplicate _id not allowed
UpsertUpdate if exists, insert if notData updates, incremental importsExistence determined based on _id
💡 Selection Recommendations
  • First-time import: It is recommended to use Insert mode to ensure data integrity.
  • Data updates: It is recommended to use Upsert mode to avoid duplicate data.

📄 Supported File Formats

JSON Format

Encoding requirements: UTF-8 encoding
Format features: Similar to the JSON Lines format, each line contains one JSON object

{"_id": "user_001", "name": "Zhang San", "age": 25, "email": "zhang@example.com"}
{"_id": "user_002", "name": "Li Si", "age": 30, "email": "li@example.com"}
{"_id": "user_003", "name": "Wang Wu", "age": 28, "email": "wang@example.com"}

CSV Format

Encoding requirements: UTF-8 encoding
Format features: The first row contains the field names, and subsequent rows contain data.

_id,name,age,email
user_001,Zhang San,25,zhang@example.com
user_002,Li Si,30,li@example.com
user_003,Wang Wu,28,wang@example.com

⚠️ Format requirements and limitations

JSON Format Specifications

Specification ItemRequirementExample
DelimiterUse the newline character \n to separate recordsOne JSON object per line
Field NamingMust not start or end with ., and must not contain consecutive ..Invalid examples: .name, name., a..b
Unique key namesNo duplicate or ambiguous key names are allowed{"a": 1, "a": 2}
Time formatUse ISODate format{"date": {"$date": "2024-01-15T10:30:00.882Z"}}

Data Integrity Requirements

PatternRequirementDescription
Insert Mode_id must be uniqueDuplicate _id not allowed in either the file or the database
Upsert modeAllows duplicate _idRecords with the same _id will be updated

📊 Import Result

After the import is completed, the system will display detailed import statistics:

  • ✅ Number of records successfully imported
  • ❌ Number of failed records and reasons
  • ⚠️ Number of skipped records (e.g., duplicate data)

📤 Collection Management Export

CloudBase supports exporting collection data to files for data backup, analysis, or migration to other systems.

🚀 Operation Procedure

  1. Access the console: Go to the CloudBase console
  2. Select collection: Switch to the Collection Management Page and select the collection to export
  3. Start Export: Click the "Export" button
  4. Configure Export: Select export format, save location, and field range
  5. Execute Export: Click "Export" to start the data export process.

📋 Export Format Configuration

JSON Format Export

Features:

  • Preserve complete data structures
  • Support nested objects and arrays
  • Export all fields by default

Field Configuration:

  • No fields specified: Export all data (recommended)
  • Specify fields: Only export specified fields.

CSV Format Export

Features:

  • Suitable for tabular data analysis
  • Compatible with tools such as Excel
  • Must specify export fields

Field Configuration Example:

// Basic fields export
_id, name, age, email

// Include system fields
_id, name, age, createdAt, updatedAt

📊 Export Options Comparison

FormatField RequirementsData IntegrityApplicable Scenarios
JSONOptionalFully preservedData backup, system migration
CSVRequiredFlattenedData analysis, Excel processing

💡 Best Practices

  • Data backup: Use JSON format, do not specify fields, and export complete data.
  • Data analysis: Use CSV format and specify the fields to be analyzed.
  • Large Datasets: Export in batches to avoid excessive data volume in a single export.
  • Nested data: CSV format requires the use of dot notation to access nested fields.