☁️ Cloud Database Practical Guide
- Beginner Zone: The "Excel Worldview" of Cloud Databases Official Documentation Portal
👉 One Sentence to Master It All:
Treat cloud databases as Excel workbooks in the cloud!
📂 Storage Zone = Excel Sheet (e.g., UserDB, OrderDB)
📑 Object Type = Sheet headers (defining field rules)
📝 Data = Cell contents (Zhang San's age, Li Si's order)
Quick Start Guide:
Log in to AGC Platform → Left menu 【My Projects】
Enter【Cloud Database】→ Right-side trio (Storage Zone/Object Types/Data)
Create structures visually (refer to config guide)
- Tablet Developers Alert! Hidden Bugs in Official Demos Painful Lesson: Official demos default to phone-only! Tablets will show blank screens!
Emergency Fix:
Locate src/main/module.json5
Modify deviceTypes:
// Wrong: Phone-only
"deviceTypes": ["phone"]
// Correct: Support both
"deviceTypes": ["phone", "tablet"] // Don’t forget the comma!
Critical! Run Build → Rebuild Project
- Hidden Workflow for Schema Modifications Rule: Cloud schema changes MUST sync locally!
Workflow:
Export schema as JSON from AGC → Object Types
Rename to schema.json
Save to AppScope/resources/rawfile/schema.json (create dir if missing)
Deadly Detail: Recompile after every schema update!
- 403 Permission Error: Ultimate Fix
When seeing this error:
Failed to upsert...403:205525004 // Translation: You have no permissions!
Check signature guide for solutions.
- Cross-Platform Nuclear Option Make CloudDB work on Android/iOS? Two approaches:
Method 1: SDK Integration (Native Devs)
// Android Example
AGConnectCloudDB cloudDB = AGConnectCloudDB.getInstance();
CloudDBZoneConfig config = new CloudDBZoneConfig("YourZone");
cloudDB.openCloudDBZone(config);
Method 2: REST API (Cross-Platform)
# Query Example
curl -X POST "https://your-api-endpoint" \
-H "Authorization: Bearer <token>" \
-d '{"query":"SELECT * FROM User"}'
- Read-Only Data? Permission Minefield Classic Fail: Can query but not modify data!
Checklist:
Object Type ACL:
AGC → Object Types → Permissions → Enable "Allow other users to write"
User Whitelist Config
Cloud Function Permissions
- Upsert 101: Dual-Purpose Operation Existing primary key → Update New primary key → Insert 📱 Local Database Survival Guide
- Debugging God Mode: Visualize Your DB Replace console.log with:
ohpm install @hadss/debug-db # One command to rule them all
Usage:
import {DebugDB} from '@hadss/debug-db';
DebugDB.initialize(context); // Get console URL
Visit http://localhost:8080/debug-db to:
Inspect RDB schemas
Edit Preferences/KVStore
- CRUD Pitfall Cheatsheet
- Transaction Kung Fu Deadlock Scenario:
// WRONG! Nested transactions
rdbStore.beginTransaction();
rdbStore.beginTransaction(); // Throws error!
Correct Approach:
try {
rdbStore.beginTransaction();
// Operation 1...
// Operation 2...
await rdbStore.commit();
} catch (e) {
rdbStore.rollback();
throw new Error("Transaction failed: " + e.message);
}
- Database Upgrade Strategies
💡 FAQ Nuclear Defense Manual
Three Golden Rules:
Design cloud DB permissions early
Wrap local operations in transactions
Check official FAQs first – save 2 hours!
Like this guide? ❤️ Like | ⭐ Bookmark
Share your pitfalls in comments! Let’s improve this together!