Data Import/Export
📥 Collection Management Import
CloudBase supports batch data import, helping you quickly migrate existing data or initialize test data.
🚀 Operation Procedure
- Access the console: Go to the CloudBase console
- Select collection: Switch to the Collection Management Page and select the target collection
- Start Import: Click the "Import" button (supports JSON and CSV formats)
- Configure Import: Select file format and conflict resolution mode
- Execute Import: Click "Import" to start the data import process.
⚙️ Conflict Resolution Mode
Mode | Behavior | Applicable Scenarios | Notes |
---|---|---|---|
Insert | Always inserts new records | Initial data import | Duplicate _id not allowed |
Upsert | Update if exists, insert if not | Data updates, incremental imports | Existence 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 Item | Requirement | Example |
---|---|---|
Delimiter | Use the newline character \n to separate records | One JSON object per line |
Field Naming | Must not start or end with . , and must not contain consecutive .. | Invalid examples: .name , name. , a..b |
Unique key names | No duplicate or ambiguous key names are allowed | ❌ {"a": 1, "a": 2} |
Time format | Use ISODate format | {"date": {"$date": "2024-01-15T10:30:00.882Z"}} |
Data Integrity Requirements
Pattern | Requirement | Description |
---|---|---|
Insert Mode | _id must be unique | Duplicate _id not allowed in either the file or the database |
Upsert mode | Allows duplicate _id | Records 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
- Access the console: Go to the CloudBase console
- Select collection: Switch to the Collection Management Page and select the collection to export
- Start Export: Click the "Export" button
- Configure Export: Select export format, save location, and field range
- 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
Format | Field Requirements | Data Integrity | Applicable Scenarios |
---|---|---|---|
JSON | Optional | Fully preserved | Data backup, system migration |
CSV | Required | Flattened | Data 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.