nocobase-db
Fungsinya
Skill ini memandu AI Anda pada lapisan database aplikasi NocoBase 3. Cocok untuk pengembang yang menambahkan tabel, migrasi, atau logika data ke aplikasi.
Kapan dipakai
- βSaat Anda perlu menambah atau mengubah tabel atau field di aplikasi NocoBase 3.
- βSaat Anda menulis kode yang membaca atau menyimpan record dan membutuhkan transaksi.
- βSaat Anda mengonfigurasi koneksi database atau menulis migrasi atau seed.
Link skill
https://github.com/nocobase/nocobase/blob/v3-develop/packages/libs/db/skills/nocobase-db/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBisakah Anda menambahkan tabel pesanan yang terhubung ke pelanggan di aplikasi NocoBase saya, menggunakan migrasi?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
AI memilih lapisan yang tepat untuk tugas tersebut: konfigurasi, migrasi, pembuat skema, atau repository runtime. Setelah itu AI menulis kode dengan API yang benar dan penanganan transaksi yang sesuai.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
The database in a NocoBase 3 application
Most mistakes here are made before the first line of code, by putting a task at the wrong layer: changing schema from runtime code, reading records through the schema builder, or reimplementing relation writes on top of raw queries.
Six areas, in the order an application grows into them:
| Area | Owns |
|---|---|
| Configuration | which databases exist, and which dialect each one speaks |
| Migrations and seeds | schema history and install data |
| Builder | how a migration declares tables, fields and constraints |
| Repository and Query | runtime reads and writes |
| Transactions | making several writes succeed or fail together |
| Collections | what the database actually resolves to, for code and for you |
The exact parameters and return types are always the TypeScript declarations in @nocobase/db. This Skill decides which API to reach for, where the code belongs, and the boundaries the types cannot express.
Where the code lives
server/config/database.ts connections and the default connection
config.yml per-environment overrides and credentials (gitignored)
database/<connection>/migrations schema history for that connection
database/<connection>/seeds install data for that connection
database/<connection>/collections resolved Collection artifacts
server/routes/, server/providers runtime reads and writes
<connection> is a connection name from server/config/database.ts, so the default connection's migrations are in database/main/migrations/. Adding a connection means adding its directory alongside and keeping database/tsconfig.json in place, so migrations and seeds are typechecked and linted as server source.
Runtime code never changes schema, and a migration never imports runtime code. That split is what these directories encode.
1. Configuration
Connections are declared in code and overridden per environment:
| Location | Responsibility |
|---|---|
server/config/database.ts |
Connection defaults through defineAppDatabaseConfig |
config.yml |
Environment overrides including credentials β gitignored |
config.example.yml |
The documented structure and credential placeholders; keep it in step |
import {
connectionEnvironment,
defineAppDatabaseConfig,
} from '@nocobase/app-server/database';
export default defineAppDatabaseConfig(
({ paths }) => ({
default: 'main',
connections: {
main: {
dialect: 'sqlite',
filename: paths.storage('database.sqlite'),
schemaManagement: 'managed',
debug: false,
},
},
}),
{ env: connectionEnvironment('main') },
);
The second argument maps environment variables onto the section: connectionEnvironment('main') declares DB_DIALECT, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_SSL and DB_FILENAME for the main connection, each overriding config.yml. Only main has them; a connection you add declares its own with a prefix naming it, connectionEnvironment('analytics', 'DB_ANALYTICS'), merged into the same env.
The dialects are sqlite, postgres, mysql, mssql, oracle, dameng, kingbase and oceanbase. Each is an optional peer of @nocobase/app-server shipped as its own package: install @nocobase/db-<dialect> into dependencies β so it reaches the deployed server β and configure the dialect. No import or driver registration is needed, and the dialect package brings its own underlying driver.
Switching a dialect means changing both layers. config.yml deep-merges into the code defaults, so editing only the code leaves a stale YAML override in place β with fields belonging to the previous dialect still applied. Remove filename
Pertanyaan umum
Bisakah saya mengubah tabel dari kode runtime biasa?
Skill menyatakan bahwa perubahan tabel harus dilakukan lewat migrasi, bukan di kode runtime.
Apakah ini untuk NocoBase 2?
Tidak. NocoBase 2 memakai paket database yang berbeda.
Apa itu seed?
Seed mengisi database dengan data instalasi yang dibutuhkan aplikasi agar bisa berjalan.
Detail
Deskripsi asli dari pembuat
Work with the database in a NocoBase 3 application: configure connections and dialects, add migrations and seeds, declare schema with the Collection Builder, read and write records with Repository or QueryAdapter, run transactions, and read Collection definitions. Use for any task under database/ or any server code that touches data. Do not use for the NocoBase 2 @nocobase/database package.
repo: nocobase/nocobase
Popularitas
- Bintang GitHub
- 25k
- Peringkat
- #10083
- Lisensi
- β
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
nocobase-app-development
25kMembantu agent Anda membangun halaman, rute, data, izin, dan tes untuk aplikasi bisnis NocoBase 3 yang lengkap.
shadcn
25kMembantu agent Anda menemukan, menambahkan, memperbaiki, dan memberi gaya komponen shadcn/ui pada proyek web, dengan memakai dokumentasi resmi dan registry-nya.
nocobase-app-plugin-development
25kMembantu agent Anda membuat dan memelihara plugin NocoBase 3 di dalam aplikasi yang sudah ada, mencakup bagian server, klien, database, dan registrasi.
nocobase-app-upgrade
25kMembantu agent Anda meningkatkan aplikasi NocoBase ke rilis template yang lebih baru, membawa perubahan template sambil tetap mempertahankan pekerjaan Anda sendiri.
Skill serupa
api-connector-builder
280kMembuat agent Anda membangun koneksi API baru mengikuti pola yang sudah ada. Gunakan saat ingin menambah integrasi lagi tanpa membuat cara baru.
api-design
280kMembantu agent Anda merancang REST API sesuai praktik terbaik. Berguna untuk mengatur cara API berkomunikasi, menampilkan error, dan mengorganisasi data.
backend-patterns
280kMembantu agent Anda dengan pola arsitektur sisi server dan optimasi database. Berguna untuk membangun atau meninjau kode yang berjalan di server.