Skip to main content

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

FeatureDescriptionApplicable Scenarios
JSON Document StorageSupport for JSON data with arbitrary structuresFlexible data structure requirements
Quick StartNo predefined data structure requiredRapid prototyping
Transaction SupportSupport for multi-document transaction operationsData consistency requirements
Native OperationsDirectly perform CRUD operationsSimple 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

CapabilityDescriptionValue
Visual DefinitionDefine data structures, field types, and relationships through the interfaceLower the development barrier and improve efficiency
Automatic ValidationEnsure data accuracy and prevent erroneous data from being storedGuarantee data quality and reduce bugs
Relationship ManagementAutomatically handle complex relationships between dataSimplify complex business logic
Built-in CMSOut-of-the-box data management backendNon-technical personnel can also manage data
AI AnalysisIntelligently mine data valueData-driven decision making
System FieldsAutomatically 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 FieldsDescriptionAutomatic Update Occasions
_idData unique identifierAutomatically generated upon creation
createdAtCreation timestampAutomatically generated upon creation
updatedAtUpdate timestampAutomatically updated on each update
_openidUser identifier (Mini Program)Automatically generated during client-side operations
ownerData ownerAutomatically set upon creation
createByCreator identifierAutomatically set upon creation
updateByLast modifierAutomatically 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".

Get Started Now