$npx -y skills add TencentCloudBase/cloudbase-skills --skill relational-database-web[Deprecated] Use when building frontend Web apps that talk to CloudBase Relational Database via @cloudbase/js-sdk – provides the canonical init pattern so you can then use Supabase-style queries from the browser. New environments should use PostgreSQL with app.rdb() — see postgre
| 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/relational-database-web/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 Relational Database Web SDK |
| 11 | |
| 12 | ## Activation Contract |
| 13 | |
| 14 | ### Use this first when |
| 15 | |
| 16 | - A browser or Web app must access CloudBase Relational Database through `@cloudbase/js-sdk`. |
| 17 | - The task is specifically about frontend initialization and browser-side query usage. |
| 18 | |
| 19 | ### Read before writing code if |
| 20 | |
| 21 | - You need to distinguish browser SDK usage from MCP database management or backend Node access. |
| 22 | - The request mentions Supabase migration, shared frontend DB client, or browser-side table queries. |
| 23 | |
| 24 | ### Then also read |
| 25 | |
| 26 | - MySQL SQL management and MCP operations -> `../relational-database-tool/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/relational-database-tool/SKILL.md`) |
| 27 | - Web auth/login -> `../auth-web/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-web/SKILL.md`) |
| 28 | - General Web app setup -> `../web-development/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/web-development/SKILL.md`) |
| 29 | |
| 30 | ### Do NOT use for |
| 31 | |
| 32 | - MCP-based SQL provisioning, schema changes, or permissions management. |
| 33 | - Backend/Node service access. |
| 34 | - Document database operations. |
| 35 | |
| 36 | ### Common mistakes / gotchas |
| 37 | |
| 38 | - Initializing SDKs in an MCP management flow. |
| 39 | - Treating `app` itself as the relational database client. |
| 40 | - Re-initializing CloudBase in every component. |
| 41 | - Mixing frontend browser access with admin-style schema mutations. |
| 42 | |
| 43 | ### Minimal checklist |
| 44 | |
| 45 | - Confirm the caller is a Web frontend. |
| 46 | - Keep one shared CloudBase app and one shared relational DB client. |
| 47 | - Route MySQL provisioning/schema work to `relational-database-tool`. If the task says PostgreSQL, CloudBase PG, PG mode, `app.rdb()`, `queryPgDatabase`, `managePgDatabase`, or RLS, route to `postgresql-development` instead. |
| 48 | - Handle auth separately before data access. |
| 49 | |
| 50 | ## Overview |
| 51 | |
| 52 | This skill standardizes the **browser-side initialization pattern** for CloudBase Relational Database. |
| 53 | |
| 54 | After initialization, use `db` with Supabase-style query patterns. |
| 55 | |
| 56 | ## Installation |
| 57 | |
| 58 | ```bash |
| 59 | npm install @cloudbase/js-sdk |
| 60 | ``` |
| 61 | |
| 62 | ## Canonical initialization |
| 63 | |
| 64 | ```javascript |
| 65 | import cloudbase from "@cloudbase/js-sdk"; |
| 66 | |
| 67 | const app = cloudbase.init({ |
| 68 | env: "your-env-id" |
| 69 | }); |
| 70 | |
| 71 | const auth = app.auth; |
| 72 | // Handle login separately |
| 73 | |
| 74 | const db = app.rdb(); |
| 75 | ``` |
| 76 | |
| 77 | ## Initialization rules |
| 78 | |
| 79 | - Initialize synchronously. |
| 80 | - Do not lazy-load the SDK with `import("@cloudbase/js-sdk")` unless the framework absolutely requires it. |
| 81 | - Create one shared `db` client and reuse it. |
| 82 | - Do not invent unsupported `cloudbase.init()` options. |
| 83 | |
| 84 | ## Quick routing |
| 85 | |
| 86 | ### Use this skill when |
| 87 | |
| 88 | - you are wiring browser components to relational tables |
| 89 | - you are replacing a Supabase browser client with CloudBase |
| 90 | - you need a canonical shared frontend `db` client |
| 91 | |
| 92 | ### Use `relational-database-tool` instead when |
| 93 | |
| 94 | - you need to create/destroy MySQL |
| 95 | - you need MySQL DDL or write-SQL administration |
| 96 | - you need to inspect or change MySQL table security rules through MCP |
| 97 | |
| 98 | ### Use `postgresql-development` instead when |
| 99 | |
| 100 | - the task says PostgreSQL, CloudBase PG, PG mode, `app.rdb()`, `queryPgDatabase`, `managePgDatabase`, PostgREST, or RLS |
| 101 | - browser-side table code must use PG semantics rather than legacy NoSQL / MySQL management tools |
| 102 | |
| 103 | ## Example: shared frontend DB client |
| 104 | |
| 105 | ```javascript |
| 106 | import cloudbase from "@cloudbase/js-sdk"; |
| 107 | |
| 108 | const app = cloudbase.init({ |
| 109 | env: "your-env-id" |
| 110 | }); |
| 111 | |
| 112 | export const db = app.rdb(); |
| 113 | ``` |
| 114 | |
| 115 | ## Example: Supabase-style query |
| 116 | |
| 117 | ```javascript |
| 118 | const { data, error } = await db |
| 119 | .from("posts") |
| 120 | .select("*") |
| 121 | .order("created_at", { ascending: false }); |
| 122 | |
| 123 | if (error) { |
| 124 | console.error("Failed to load posts", error.message); |
| 125 | } |
| 126 | ``` |
| 127 | |
| 128 | ## Example: inse |