Data Import/Export
Collection Management Import
CloudBase supports batch data import, helping you quickly migrate existing data or initialize test data.
Operation Process
- Select Collection: Switch to Cloud Development Platform/Collection Management, select 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 the "Import" button to start the data import process

Conflict Resolution Mode
| Mode | Behavior | Applicable Scenarios | Notes |
|---|---|---|---|
| Insert | Always insert new records | Completely new data import | Cannot have duplicate _id |
| Upsert | Update if exists, insert if not | Data update, incremental import | Determine existence based on _id |
Tip
- For the first import: It is recommended to use Insert mode to ensure data integrity
- Data update: It is recommended to use Upsert mode to avoid duplicate data
Supported File Formats
JSON Format
Encoding requirements: UTF-8 encoding
Format characteristics: Similar to JSON Lines format, with one JSON object per line
{"_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 characteristics: The first row contains 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 | Cannot start or end with ., cannot contain consecutive .. | ❌ .name, name., a..b |
| Unique Key Names | Must not have duplicate or ambiguous key names | ❌ {"a": 1, "a": 2} |
| Time Format | Use the ISODate format | {"date": {"$date": "2024-01-15T10:30:00.882Z"}} |
Data Integrity Requirements
| Mode | Requirement | Description |
|---|---|---|
| Insert Mode | _id must be unique | No duplicate _id allowed within the file or in the database |
| Upsert Mode | Allows duplicate _id | Records with the same _id will be updated |
Import Results
After the import is completed, the system will display detailed import statistics:
- Number of successfully imported records
- 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 Process
- Access the console: Go to the Tencent Cloud Development Platform
- Select Collection: Switch to Cloud Development Platform/Collection Management, select the collection to export.
- Start export: Click the "Export" button
- Configure export: Select export format, save location, and field range
- Execute export: Click the "Export" button to start the data export process
Export Format Configuration
JSON Format Export
Features:
- Retain the complete data structure
- Supports nested objects and arrays
- Exports all fields by default
Field Configuration:
- Without specifying fields: Exports all data (Recommended)
- Specify fields: Exports only the 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 | Full retention | Data backup, system migration |
| CSV | Required | Flattened processing | Data analysis, Excel processing |
Best Practices
- Data backup: Use JSON format without specifying fields to export complete data.
- Data analysis: Use CSV format to specify the fields to be analyzed.
- Large datasets: Export in batches to prevent excessive data volume in a single export operation
- Nested data: CSV format requires the use of dot notation to access nested fields