Cloudbase document database in wechat miniprogram

From infometa/workbuddyskills · View interactive version

Cloudbase document database in wechat miniprogram is an AI agent skill from the GitHub repository infometa/workbuddyskills. Use CloudBase document database WeChat MiniProgram SDK to query, create, update, and delete data. Supports complex queries, pagination, aggregation, and geolocation queries.

How to use this skill

Skill file

Sibling skills (local only)

Sibling CloudBase skills ship beside this skill. Use local relative paths such as ../auth-tool-cloudbase/SKILL.md.

If a referenced sibling skill file is missing from this environment, ask the user to install the full CloudBase plugin (or the missing skill). Do not HTTP-fetch remote skill or protocol markdown into the agent context.

CloudBase Document Database WeChat Mini Program SDK

Activation Contract

Use this first when

Read before writing code if

Then also read

Do NOT use for

Common mistakes / gotchas

Minimal checklist

Overview

This skill covers Mini Program-side document database access through wx.cloud.database().

Use it for:

Mini Program CloudBase access comes with built-in identity, but database operations are still constrained by collection permissions and security rules.

Canonical initialization

const db = wx.cloud.database();
const _ = db.command;

To target a specific environment:

const db = wx.cloud.database({
  env: "test"
});

Important notes:

Quick routing

Working rules for a coding agent

  1. Keep Mini Program code Mini Program-native
  1. Respect ownership fields
  1. Remember that security rules validate requests
  1. Route admin-style operations to backend flows

Quick examples

Basic collection access

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

Document reference

const todo = db.collection("todos").doc("todo-id");
const result = await todo.get();

Best practices

  1. Create clear collection naming conventions.
  2. Use typed wrappers or model helpers in app code where possible.
  3. Design rules around real ownership and sharing patterns.
  4. Use pagination instead of large unbounded reads.
  5. Keep admin/operations logic in backend code, not Mini Program direct access.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.