$npx -y skills add TencentCloudBase/cloudbase-skills --skill no-sql-web-sdkUse CloudBase document database Web SDK only for confirmed NoSQL collection work. Query, create, update, and delete document data; if the task mentions PostgreSQL / CloudBase PG / app.rdb(), route to postgresql-development instead.
| 1 | ## Standalone Install Note |
| 2 | |
| 3 | If this environment only installed the current skill, start from the CloudBase main entry and use the published `cloudbase/references/...` paths for sibling skills. |
| 4 | |
| 5 | - CloudBase main entry: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/SKILL.md` |
| 6 | - Current skill raw source: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/no-sql-web-sdk/SKILL.md` |
| 7 | |
| 8 | Keep local `references/...` paths for files that ship with the current skill directory. When this file points to a sibling skill such as `auth-tool` or `web-development`, use the standalone fallback URL shown next to that reference. |
| 9 | |
| 10 | # CloudBase Document Database Web SDK |
| 11 | |
| 12 | ## Activation Contract |
| 13 | |
| 14 | ### Use this first when |
| 15 | |
| 16 | - A browser or Web app must read or write CloudBase document database data through `@cloudbase/js-sdk`. |
| 17 | - The request mentions `app.database()`, `db.collection()`, `.where()`, `.watch()`, pagination, aggregation, or geolocation queries in a Web frontend. |
| 18 | |
| 19 | ### Read before writing code if |
| 20 | |
| 21 | - The task is clearly browser-side, but you still need to decide between Web SDK, Mini Program SDK, or backend access. |
| 22 | - The request touches login state, collection permissions, or realtime updates. |
| 23 | |
| 24 | ### Then also read |
| 25 | |
| 26 | - Web login and caller identity -> `../auth-web/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-web/SKILL.md`) |
| 27 | - General Web app structure -> `../web-development/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/web-development/SKILL.md`) |
| 28 | - Mini Program database code -> `../no-sql-wx-mp-sdk/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/no-sql-wx-mp-sdk/SKILL.md`) |
| 29 | |
| 30 | ### Do NOT use for |
| 31 | |
| 32 | - Mini Program code using `wx.cloud.database()`. |
| 33 | - Server-side or cloud-function database access. |
| 34 | - SQL / MySQL database operations. |
| 35 | - Pure resource-permission administration with no browser SDK code. |
| 36 | - **NEW business tables that the task explicitly asks to put in CloudBase PostgreSQL (CloudBase PG).** Before applying this skill, call `envQuery(action="info", envId=...)` and read `EnvInfo.RuntimeBackends`. If `postgresql === true` AND the task asks for a new business table to live in PG, switch to the `postgresql-development` skill for that table: it goes through `app.rdb()`, uses PG row-level security (`CREATE POLICY`), and uploads via `app.storage.from('<bucket>').upload('<key>', file)` against an explicitly-created pgstore bucket. |
| 37 | - Existing NoSQL collections in the same env keep using THIS skill — PG and NoSQL coexist in CloudBase PG environments. The rule is "follow the task / existing surface", not "PG env forbids NoSQL". |
| 38 | |
| 39 | ### SDK Code vs MCP Tools |
| 40 | |
| 41 | **When to write SDK code (use this skill):** |
| 42 | - The task explicitly asks to "modify code" or "use SDK" |
| 43 | - The task asks to implement app/frontend logic |
| 44 | - The task mentions specific SDK methods like `db.collection().add()`, `.get()`, `.update()` |
| 45 | - The context shows an existing Web project with SDK initialization (e.g., `index.js` already has `cloudbase.init()`) |
| 46 | |
| 47 | **When to use MCP tools instead:** |
| 48 | - The task asks to manage CloudBase resources (create collection, set permissions, etc.) |
| 49 | - The task involves admin/management operations without writing app code |
| 50 | - The task mentions tools like `writeNoSqlDatabaseContent`, `managePermissions`, etc. |
| 51 | |
| 52 | **Key distinction:** If the user says "使用 JS SDK 执行 XX 操作" (use JS SDK to perform XX operation) or "修改代码" (modify code), write SDK code in the project files. Do not use MCP database write tools for app-level data operations. |
| 53 | |
| 54 | ### Common mistakes / gotchas |
| 55 | |
| 56 | - Querying before the user is signed in when the collection rules require identity. |
| 57 | - Using `wx.cloud.database()` or Node SDK patterns in browser code. |
| 58 | - Initializing CloudBase lazily with dynamic imports instead of a shared synchronous app instance. |
| 59 | - Treating security rules as result filters rather than request validators. |
| 60 | - **Expecting a `CUSTOM` security rule to take effect immediately after you call `managePermissions(updateResourcePermission)`.** The backend caches rule evaluators for **2–5 minutes**; first writes after a rule change may silently fail or be rejected with `DATABASE_PERMISSION_DENIED` even when the expression is correct. Either (a) wait a few minutes and retry the same write before assuming the rule is wrong, or (b) verify the rule is live by reading `result.code` / `result.message` on every write and by d |