cloudbase-document-database-web-sdk
Use CloudBase document database Web SDK to query, create, update, and delete data. Supports complex queries, pagination, aggregation, and geolocation queries.
Install
mkdir -p .claude/skills/cloudbase-document-database-web-sdk && curl -L -o skill.zip "https://mcp.directory/api/skills/download/3408" && unzip -o skill.zip -d .claude/skills/cloudbase-document-database-web-sdk && rm skill.zipInstalls to .claude/skills/cloudbase-document-database-web-sdk
About this skill
CloudBase Document Database Web SDK
This skill provides guidance on using the CloudBase document database Web SDK for data operations in web applications.
Core Concepts
Initialization
Before using any database operations, initialize the CloudBase SDK:
import cloudbase from "@cloudbase/js-sdk";
// UMD version
// If you are not using npm, And want to use UMD version instead. You should refer to https://docs.cloudbase.net/quick-start/#web-%E5%BF%AB%E9%80%9F%E4%BD%93%E9%AA%8C for latest version of UMD version.
const app = cloudbase.init({
env: "your-env-id", // Replace with your environment id
});
const db = app.database();
const _ = db.command; // Get query operators
// ... login
Remember to sign in(auth) is *REQUIRED before actually querying the database.
Collection Reference
Access collections using:
db.collection('collection-name')
Query Operators
CloudBase provides query operators via db.command (aliased as _):
_.gt(value)- Greater than_.gte(value)- Greater than or equal_.lt(value)- Less than_.lte(value)- Less than or equal_.eq(value)- Equal to_.neq(value)- Not equal to_.in(array)- Value in array_.nin(array)- Value not in array
Basic Operations
Query Single Document
Query by document ID:
const result = await db.collection('todos')
.doc('docId')
.get();
Query Multiple Documents
Query with conditions:
const result = await db.collection('todos')
.where({
completed: false,
priority: 'high'
})
.get();
Note: get() returns 100 records by default, maximum 1000.
Query Methods Chaining
Combine methods for complex queries:
.where(conditions)- Filter conditions.orderBy(field, direction)- Sort by field ('asc' or 'desc').limit(number)- Limit results (default 100, max 1000).skip(number)- Skip records for pagination.field(object)- Specify fields to return (true/false)
Advanced Features
For detailed information on specific topics, refer to:
CRUD Operations
See ./crud-operations.md for:
- Creating documents (add, batch add)
- Updating documents (partial updates, operators)
- Deleting documents (conditional delete, soft delete)
- Complete CRUD manager examples
Complex Queries
See ./complex-queries.md for:
- Using query operators
- Combining multiple conditions
- Field selection
- Sorting and limiting results
Pagination
See ./pagination.md for:
- Implementing page-based navigation
- Calculating skip and limit values
- Cursor-based pagination
- Infinite scroll patterns
Aggregation Queries
See ./aggregation.md for:
- Grouping data
- Statistical calculations
- Pipeline operations
- Time-based aggregations
Geolocation Queries
See ./geolocation.md for:
- Proximity searches
- Area-based queries
- Geographic indexing requirements
- Distance-based features
Realtime Database
See ./realtime.md for:
- Real-time data synchronization using watch() method
- Setting up listeners for document changes
- Handling real-time updates in chat and collaboration apps
- Performance optimization and error handling
- Common patterns for real-time applications
Security Rules
See ./security-rules.md for:
- Configuring database permissions
- Simple permissions vs custom rules
- Permission categories and usage
- Security rule syntax and examples
Common Patterns
Error Handling
Always wrap database operations in try-catch:
try {
const result = await db.collection('todos').get();
console.log(result.data);
} catch (error) {
console.error('Database error:', error);
}
Return Value Structure
Database operations return:
{
data: [...], // Array of documents
// Additional metadata
}
Important Notes
- Environment ID: Replace
"your-env-id"with actual CloudBase environment ID - Default Limits:
get()returns 100 records by default - Collection Names: Use string literals for collection names
- Geolocation Index: Geographic queries require proper indexing
- Async/Await: All database operations are asynchronous
Best Practices
- Initialize SDK once at application startup
- Reuse database instance across the application
- Use query operators for complex conditions
- Implement pagination for large datasets
- Select only needed fields to reduce data transfer
- Handle errors appropriately
- Create indexes for frequently queried fields
Coding Rules
- It is HIGHLY RECOMMENDED to have a type definition and model layer for each collection in your document database. This will help you to avoid errors and make your code more robust. That would be the single source of truth for your database schema. Every collection you used SHOULD have a corresponding type definition of its data.
- Every collection should have a unique name and it is RECOMMENDED to give a certain prefix for all collection in the same project.
- Collections should have well defined and meaningful security rules(policy) for create, read, write and delete permission according to the business logic. Details refer to
./security-rules.md. When writing expressions in security rules, The type definition of the collection mention above can be used as the type reference.
Quick Reference
Common query examples:
// Simple query
db.collection('todos').where({ status: 'active' }).get()
// With operators
db.collection('users').where({ age: _.gt(18) }).get()
// Pagination
db.collection('posts')
.orderBy('createdAt', 'desc')
.skip(20)
.limit(10)
.get()
// Field selection
db.collection('users')
.field({ name: true, email: true, _id: false })
.get()
For more detailed examples and advanced usage patterns, refer to the companion reference files in this directory.
Error handling
EVERY database operation(including get(), add(), update(), delete() etc)should check the return value's code for any errors. For example:
const result = await db.collection('todos').add(newTodo);
if(typeof result.code === 'string') {
// Handle error ...
}
Error MUST be handled with detail and human-readable message and friendly UI.
More by TencentCloudBase
View all skills by TencentCloudBase →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversConnect Supabase projects to AI with Supabase MCP Server. Standardize LLM communication for secure, efficient developmen
Manage PostgreSQL connections, create a Postgres database, inspect schemas, and run SQL queries. Supports setting Postgr
SurrealDB is a versatile graph database supporting graph, document, and relational data with powerful query and bulk man
Use Firebase as database for real-time data management. Integrate with database on Firebase to securely query, list, and
ExoQuery — a Kotlin compile-time SQL library with docs, validation, and execution tools for safer, faster database code.
MCP Toolbox for Databases by Google. An open-source server that lets AI agents query Cloud SQL, Spanner, AlloyDB, and ot
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.