Overview
Document database is a database service provided by CloudBase, supporting flexible JSON document storage and including two core features: collection management and data model.
Collection Management
Collection Management is a basic data storage service provided by CloudBase, based on document database, offering developers flexible JSON document storage capabilities.
Core Features
| Feature | Description | Applicable Scenarios |
|---|---|---|
| JSON Document Storage | Support for JSON data with arbitrary structures | Flexible data structure requirements |
| Quick Start | No predefined data structure required | Rapid prototyping |
| Transaction Support | Support for multi-document transaction operations | Data consistency requirements |
| Native Operations | Directly perform CRUD operations | Simple data management |
Creation Methods
Method 1: Mini Program IDE Side

Method 2: CloudBase Platform

Data Model
Document data model is an upper-layer modeling based on collections, providing capabilities such as visual definition, automatic validation, association management, and built-in CMS, helping developers rapidly build business databases.
For specific data model features, please refer to data model.

Core Features
| Capability | Description | Value |
|---|---|---|
| Visual Definition | Define data structures, field types, and relationships through the interface | Lower the development barrier and improve efficiency |
| Automatic Validation | Ensure data accuracy and prevent erroneous data from being stored | Guarantee data quality and reduce bugs |
| Relationship Management | Automatically handle complex relationships between data | Simplify 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 manage data identifiers, timestamps, user information, etc. | Reduce boilerplate code and focus on business |
Intelligent System Field Management
When operating data models, the system automatically adds the following system fields and maintains them during data operations:
| System Fields | Description | Automatic Update Occasions |
|---|---|---|
_id | Data unique identifier | Automatically generated upon creation |
createdAt | Creation timestamp | Automatically generated upon creation |
updatedAt | Update timestamp | Automatically updated on each update |
_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 each update |
💡 Note: 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
Assuming a document-based data model named users is created, user user123 inserts the following structured data through the data model:
{
"name": "Zhang San",
"email": "zhangsan@example.com",
"age": 25
}
Complete data automatically added by the system:
{
"_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"
}
Creating Data Models via Collections
Since the data model is an upper-layer modeling based on collections, when creating a document-based data model, the corresponding collection will be automatically created.
However, when creating a collection, the corresponding data model will not be automatically created.
Therefore, on the Cloud Development Platform/Data Model page, you can select "Create Model Based on Collection".
