Overview
The document database is a database service provided by CloudBase, supporting flexible JSON document storage, and includes two core features: collection management and data model.
📄 Collection Management
Collection Management is a basic data storage service provided by CloudBase, based on the FlexDB document database, offering developers flexible JSON document storage capabilities.
🎯 Core Features
Feature | Description | Applicable Scenarios |
---|---|---|
📄 JSON Document Storage | Supports JSON data of any structure | Flexible data structure requirements |
🚀 Quick Start | No predefined data structure required | Rapid prototyping |
🔄 Transaction Support | Supports multi-document transaction operations | Data consistency requirements |
🛠️ Native Operations | Direct CRUD operations | Simple data management |
📋 Creation Methods
Method 1: Mini Program IDE client-side
Method 2: Cloud Development Platform
🗄️ Data Model
Document-based data model is a higher-level modeling approach based on collections, providing capabilities including visual definition, automatic validation, relationship management, and built-in CMS to help developers rapidly build business databases.
For specific data model functionalities, please refer to Data Model
🎯 Core Features
Capability | Description | Value |
---|---|---|
📋 Visual Definition | Define data structures, field types, and relationships through the interface | Lowers development barriers and improves efficiency |
🛡️ Automatic Validation | Ensure data accuracy and prevent erroneous data from being stored | Guarantee data quality and reduce bugs |
🔗 Relationship Management | Automatically handles complex relationships between data | Simplifies complex business logic |
🎛️ Built-in CMS | Out-of-the-box data management backend | Non-technical personnel can also manage data |
🤖 AI Analysis | Intelligently mine data value | Data-driven decision making |
⚙️ System Fields | Automatically manages data identifiers, timestamps, user information, etc. | Reduces boilerplate code and focuses on business logic |
⚙️ Intelligent System Field Management
When operating the data model, the system automatically adds the following system fields and maintains them during data operations:
System Field | Description | Automatic Update Timing |
---|---|---|
_id | Data unique identifier | Automatically generated upon creation |
createdAt | Creation timestamp | Automatically generated upon creation |
updatedAt | Update timestamp | Automatically updated on every change |
_openid | User identifier (Mini Program) | Automatically generated during client-side operations |
owner | Data owner | Automatically set upon creation |
createBy | Creator identifier | Automatically set upon creation |
updateBy | Last modifier | Automatically updated on every change |
💡 Development Advantage: Developers do not need to manually manage these fields. The system automatically handles data lifecycle management, allowing you to focus on business logic implementation.
Practical Application Example
Suppose a document data model named users
has been created:
User
user123` added the following structured data via the data model
{
"name": "Zhang San",
"email": "zhangsan@example.com",
"age": 25
}
System-Automatically Added Complete Data:
{
"_id": "64f1a2b3c4d5e6f7g8h9i0j1",
"name": "Zhang San",
"email": "zhangsan@example.com",
"age": 25,
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z",
"_openid": "user123",
"owner": "user123",
"createBy": "user123",
"updateBy": "user123"
}
Create Data Model via Collection
Since the data model is higher-level modeling based on collections, creating a document-based data model will automatically create the corresponding collections.
But when creating a collection, the corresponding data model will not be automatically created.
Therefore, on the Cloud Development/Data Model page, you can select Create Model Based on Collection.