nocobase-db
यह क्या करती है
यह स्किल NocoBase 3 ऐप की डेटाबेस परत में आपके AI का मार्गदर्शन करती है। यह उन डेवलपर्स के लिए है जो ऐप में टेबल, माइग्रेशन या डेटा लॉजिक जोड़ते हैं।
कब इस्तेमाल करें
- ✓जब आपको NocoBase 3 ऐप में कोई टेबल या फ़ील्ड जोड़ना या बदलना हो।
- ✓जब आप ऐसा कोड लिखें जो रिकॉर्ड पढ़ता या सेव करता है और जिसमें ट्रांज़ैक्शन चाहिए।
- ✓जब आप डेटाबेस कनेक्शन सेट करें या माइग्रेशन या सीड लिखें।
Skill का लिंक
https://github.com/nocobase/nocobase/blob/v3-develop/packages/libs/db/skills/nocobase-db/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“क्या आप मेरे NocoBase ऐप में माइग्रेशन का उपयोग करके एक orders टेबल जोड़ सकते हैं, जो customers से जुड़ी हो?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
AI कार्य के लिए सही परत चुनता है: कॉन्फ़िगरेशन, माइग्रेशन, स्कीमा बिल्डर या रनटाइम रिपॉज़िटरी। फिर वह सही API और ट्रांज़ैक्शन हैंडलिंग के साथ कोड लिखता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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
अक्सर पूछे जाने वाले सवाल
क्या मैं सामान्य रनटाइम कोड से टेबल बदल सकता हूँ?
स्किल बताती है कि टेबल में बदलाव माइग्रेशन में होने चाहिए, रनटाइम कोड में नहीं।
क्या यह NocoBase 2 के लिए है?
नहीं। NocoBase 2 में एक अलग डेटाबेस पैकेज इस्तेमाल होता है।
सीड क्या होता है?
सीड डेटाबेस को वह इंस्टॉल डेटा भरता है जिसकी ऐप को शुरू होने के लिए ज़रूरत होती है।
जानकारी
लेखक का मूल विवरण
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
लोकप्रियता
- GitHub स्टार
- 25k
- रैंकिंग में स्थान
- #10083
- लाइसेंस
- —
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
nocobase-app-development
25kयह आपके एजेंट को पूर्ण NocoBase 3 व्यावसायिक एप्लिकेशन के लिए पेज, routes, डेटा, अनुमतियाँ और टेस्ट बनाने में मदद करती है।
shadcn
25kयह आपके एजेंट को वेब प्रोजेक्ट में shadcn/ui कंपोनेंट खोजने, जोड़ने, ठीक करने और स्टाइल करने में मदद करती है, उनके आधिकारिक दस्तावेज़ और registries का उपयोग करके।
nocobase-app-plugin-development
25kयह आपके एजेंट को मौजूदा NocoBase 3 ऐप के भीतर plugins बनाने और उनकी देखभाल करने में मदद करती है, जिसमें server, client, database और registration के हिस्से शामिल हैं।
nocobase-app-upgrade
25kयह आपके एजेंट को NocoBase ऐप को नए template रिलीज़ तक अपग्रेड करने में मदद करती है, template के बदलाव लाते हुए आपका अपना काम बनाए रखते हुए।
मिलती-जुलती skills
api-connector-builder
280kयह आपके एजेंट को मौजूदा pattern के हिसाब से नए API connections बनाने देता है। जब बिना कोई नया तरीका बनाए एक और integration जोड़ना हो, तब इसका इस्तेमाल करें।
api-design
280kयह आपके एजेंट को best practices के हिसाब से REST APIs डिज़ाइन करने में मदद करता है। यह तय करने में काम आता है कि APIs आपस में कैसे बात करें, errors कैसे दिखें, और data को कैसे व्यवस्थित करें।
backend-patterns
280kआपके एजेंट को server-side architecture patterns और database optimization में मदद करता है। server पर चलने वाला code बनाने या review करने के लिए उपयोगी है।