Cloud

cloudbase-document-database-web-sdk

tencentcloudbase/skills · updated Apr 8, 2026

$npx skills add https://github.com/tencentcloudbase/skills --skill cloudbase-document-database-web-sdk
summary

CloudBase document database Web SDK for querying, creating, updating, and deleting data in web applications.

  • Supports CRUD operations, complex queries with operators (gt, gte, lt, lte, eq, neq, in, nin), and method chaining for filtering, sorting, and field selection
  • Includes pagination via skip/limit, aggregation pipelines, geolocation queries, and real-time data synchronization with watch() listeners
  • Requires SDK initialization with environment ID and authentication before database
skill.md

CloudBase Document Database Web SDK

Activation Contract

Use this first when

  • A browser or Web app must read or write CloudBase document database data through @cloudbase/js-sdk.
  • The request mentions app.database(), db.collection(), .where(), .watch(), pagination, aggregation, or geolocation queries in a Web frontend.

Read before writing code if

  • The task is clearly browser-side, but you still need to decide between Web SDK, Mini Program SDK, or backend access.
  • The request touches login state, collection permissions, or realtime updates.

Then also read

  • Web login and caller identity -> ../auth-web/SKILL.md
  • General Web app structure -> ../web-development/SKILL.md
  • Mini Program database code -> ../no-sql-wx-mp-sdk/SKILL.md

Do NOT use for

  • Mini Program code using wx.cloud.database().
  • Server-side or cloud-function database access.
  • SQL / MySQL database operations.
  • Pure security-rule administration with no browser SDK code.

Common mistakes / gotchas

  • Querying before the user is signed in when the collection rules require identity.
  • Using wx.cloud.database() or Node SDK patterns in browser code.
  • Initializing CloudBase lazily with dynamic imports instead of a shared synchronous app instance.
  • Treating security rules as result filters rather than request validators.
  • Forgetting pagination or indexes for larger collections.

Minimal checklist

  • Confirm this is browser-side document database work.
  • Initialize CloudBase once and reuse the same app / db instance.
  • Verify auth expectations before CRUD.
  • Read the right companion reference file for the specific operation.

Overview

This skill covers browser-side document database usage via @cloudbase/js-sdk.

Use it for:

  • CRUD in a Web app
  • complex queries and pagination
  • aggregation
  • realtime listeners with watch()
  • geolocation queries

Canonical initialization

import cloudbase from "@cloudbase/js-sdk";

const app = cloudbase.init({
  env: "your-env-id"
});

const db = app.database();
const _ = db.command;

Important rules:

  • Sign in before querying if the collection rules require identity.
  • Keep a single shared app/database instance.
  • Do not hide initialization inside ad-hoc async loaders unless the framework truly requires it.

Quick routing

  • CRUD -> ./crud-operations.md
  • Complex queries -> ./complex-queries.md
  • Pagination -> ./pagination.md
  • Aggregation -> ./aggregation.md
  • Realtime listeners -> ./realtime.md
  • Geolocation -> ./geolocation.md
  • Security rules -> ./security-rules.md

Working rules for a coding agent

  1. Start from the auth model

    • If the page relies on logged-in user identity, read the Web auth skill before writing database code.
  2. Keep browser code browser-native

    • Use app.database() and collection references.
    • Do not mix in MCP management flows or SQL mental models.
  3. Respect security rules

    • Collection rules can reject requests before data is read.
    • If the task fails with permission issues, inspect the rule model rather than assuming the query syntax is wrong.
  4. Return user-friendly errors

    • Database errors must become readable UI or application errors, not silent failures.

Quick examples

Simple query

const result = await db.collection("todos")
  .where({ completed: false })
  .get();

Ordered pagination

const result = await db.collection("posts")
  .orderBy("createdAt", "desc")
  .skip(20)
  .limit(10)
  .get();

Field selection

const result = await db.collection("users")
  .field({ name: true, email: true, _id: false })
  .get();

Best practices

  1. Define collection-level types or model wrappers in the app code.
  2. Use meaningful collection naming conventions.
  3. Select only required fields.
  4. Add indexes for frequent filters or sort keys.
  5. Pair frontend CRUD with explicit security-rule design.
  6. Use pagination instead of unbounded reads.

Error handling

try {
  const result = await db.collection("todos").get();
  console.log(result.data);
} catch (error) {
  console.error("Database error:", error);
}

When the SDK returns an operation result, check error indicators and translate them into readable application behavior.

general reviews

Ratings

4.425 reviews
  • Ren Liu· Dec 8, 2024

    cloudbase-document-database-web-sdk reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Ren Farah· Nov 27, 2024

    Registry listing for cloudbase-document-database-web-sdk matched our evaluation — installs cleanly and behaves as described in the markdown.

  • William Martinez· Nov 19, 2024

    Keeps context tight: cloudbase-document-database-web-sdk is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Isabella Choi· Nov 7, 2024

    cloudbase-document-database-web-sdk has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Mei Dixit· Oct 26, 2024

    Useful defaults in cloudbase-document-database-web-sdk — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Sakura Haddad· Oct 18, 2024

    Keeps context tight: cloudbase-document-database-web-sdk is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Mei Rao· Sep 17, 2024

    cloudbase-document-database-web-sdk fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Sakshi Patil· Sep 9, 2024

    Solid pick for teams standardizing on skills: cloudbase-document-database-web-sdk is focused, and the summary matches what you get after install.

  • Chaitanya Patil· Aug 28, 2024

    We added cloudbase-document-database-web-sdk from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Mei Robinson· Aug 8, 2024

    cloudbase-document-database-web-sdk is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

showing 1-10 of 25

1 / 3