nocobase-app-plugin-repository-example

Demonstrates NocoBase Repository API queries, CRUD, relations, and aggregates through example pages.

9|3|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/nocobase/nocobase3 --skill nocobase-app-plugin-repository-example-nocobase
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nocobase-app-plugin-repository-example
Source: https://github.com/nocobase/nocobase3/tree/main/packages/examples/app-plugin-repository-example/skills/nocobase-app-plugin-repository-example
Command: npx skills add https://github.com/nocobase/nocobase3 --skill nocobase-app-plugin-repository-example-nocobase

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers learning the NocoBase 3 Repository HTTP adapter lack a concrete, runnable reference showing how findMany queries, CRUD operations, relation writes, optimistic locking, atomic updates, and aggregate queries behave end to end. ## Core Features & Use Cases - Repository query demos: Array and streamed NDJSON findMany, sorting, select-combine ASTs, and aggregate/groupBy panels with visible request and response payloads. - CRUD and relation workflows: CRM and order management pages with detail routes, drawer-based editing, optimistic locking via ifVersion, and 20 supported relationship-write combinations (create/connect/disconnect/set/update/upsert/delete). - Use Case: A developer integrating the Repository API opens the relation-mutations page to inspect exact request ASTs for hasMany task creation with assignee.connect, then replicates the pattern in their own plugin. ## Quick Start Register the repository-example plugin, run migrations and seeds, then open the Repository examples pages to try each Repository API operation.

Frequently Asked Questions about nocobase-app-plugin-repository-example

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use the NocoBase Repository API for findMany queries?▼

Call api.repository(name).findMany(options) with a JSON AST to get an array response, or iterate with for await to receive framed NDJSON records as they stream. Each query supports only one consumption mode, so create separate queries for array and streamed results.

How to perform relation writes like connect and set in NocoBase?▼

Use relation mutation operations on hasOne, hasMany, or belongsToMany relations: create, connect, disconnect, set, update, upsert, and delete, with 20 supported combinations. Set applies only to to-many relations, and many-to-many tag operations permit only the role through field.

Does the Repository API support optimistic locking?▼

Yes, orders use optimistic locking via a version field. Preserve version when editing and send ifVersion with updates; on a 409 conflict, refresh the record rather than overwriting it.

What is a Repository Policy in NocoBase and why is it required?▼

A Repository Policy defines allowed read, create, update, and delete operations per exposure, written directly or built with buildRepositoryPolicy, where unmentioned nodes are denied. Policies stay server-side; requests carrying policy or scope fields are rejected.

Can I use this example plugin as a production CRM?▼

No, the plugin is a demonstration with no per-role or tenant authorization; every signed-in user can manage all records. A production adaptation must design its own authorization boundary and must not store unrelated application data in its tables.

Why are my Repository aggregate results showing NULL values?▼

Empty-set sums and price metrics return NULL by design, and AVG is unweighted. Separate panel queries are not a single snapshot, so results may differ if data changes between requests.