一键导入
source-command-convex-helpers-guide
Quick reference for convex-helpers utilities available in this project - custom functions, relationships, validators, and more
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Quick reference for convex-helpers utilities available in this project - custom functions, relationships, validators, and more
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | source-command-convex-helpers-guide |
| description | Quick reference for convex-helpers utilities available in this project - custom functions, relationships, validators, and more |
Use this skill when the user asks to run the migrated source command convex-helpers-guide.
This project includes convex-helpers (v0.1.108). Always prefer these helpers over custom implementations.
For comprehensive documentation, see docs/CONVEX_HELPERS.md.
The single most useful pattern from convex-helpers. Create auth-enforced wrappers:
import {
customQuery,
customMutation,
} from "convex-helpers/server/customFunctions";
import { query, mutation } from "../_generated/server";
import { authComponent } from "../auth";
export const authedQuery = customQuery(query, {
args: {},
input: async (ctx, args) => {
const user = await authComponent.getAuthUser(ctx);
if (!user) throw new Error("Not authenticated");
return { ctx: { ...ctx, user }, args };
},
});
Traverse database relationships without manual queries:
import {
getOneFromOrThrow,
getManyFrom,
} from "convex-helpers/server/relationships";
// Get one related document (throws if not found)
const user = await getOneFromOrThrow(ctx.db, "users", "by_email", email);
// Get many related documents
const tasks = await getManyFrom(ctx.db, "tasks", "by_userId", userId);
Beyond standard v.*:
import {
nullable,
literals,
partial,
brandedString,
} from "convex-helpers/validators";
// Nullable (value OR null)
nullable(v.string()); // v.union(v.string(), v.null())
// Literals shorthand
literals("admin", "user", "guest"); // v.union(v.literal("admin"), ...)
// Partial (all fields optional)
partial(myObjectValidator);
// Branded strings for type safety
const EmailAddress = brandedString("email");
import {
asyncMap,
pick,
omit,
nullThrows,
withoutSystemFields,
} from "convex-helpers";
// Map async operations
const users = await asyncMap(userIds, (id) => ctx.db.get(id));
// Pick/omit fields
const publicUser = pick(user, ["name", "email"]);
const noTimestamps = omit(user, ["_creationTime"]);
// Assert non-null
const user = nullThrows(await ctx.db.get(userId), "User not found");
// Remove _id and _creationTime
const cleanData = withoutSystemFields(document);
| Feature | Import Path |
|---|---|
| Custom Functions | convex-helpers/server/customFunctions |
| Relationships | convex-helpers/server/relationships |
| Validators | convex-helpers/validators |
| Utilities | convex-helpers |
| Filter Helper | convex-helpers/server/filter |
| Pagination | convex-helpers/server/pagination |
| React Hooks | convex-helpers/react |
| Sessions | convex-helpers/server/sessions |
| Migrations | convex-helpers/server/migrations |
| Triggers | convex-helpers/server/triggers |
| Need | Helper |
|---|---|
| Auth in every function | customQuery / customMutation |
| Get related records | getOneFromOrThrow / getManyFrom |
| Complex filtering (rare) | filter() helper |
| Paginate large datasets | getPage / paginator |
| Null-safe access | nullThrows |
| Clean API responses | withoutSystemFields / pick / omit |
Refer to docs/CONVEX_HELPERS.md for detailed examples and advanced patterns.
Set up Convex authentication with proper user management, identity mapping, and access control patterns. Use when implementing auth flows.
Guide to using Convex components for feature encapsulation. Learn about sibling components, creating your own, and when to use components vs monolithic code.
Discover and use convex-helpers utilities for relationships, filtering, sessions, custom functions, and more. Use when you need pre-built Convex patterns.
Create Convex queries, mutations, and actions with proper validation, authentication, and error handling. Use when implementing new API endpoints.
Plan and execute Convex schema migrations safely, including adding fields, creating tables, and data transformations. Use when schema changes affect existing data.
Design and generate Convex database schemas with proper validation, indexes, and relationships. Use when creating schema.ts or modifying table definitions.