본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)25k · #10083

nocobase-db

하는 일

이 스킬은 NocoBase 3 앱의 데이터베이스 계층에서 AI를 안내합니다. 테이블, 마이그레이션, 데이터 로직을 추가하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓NocoBase 3 앱의 테이블이나 필드를 추가하거나 바꿔야 할 때.
  • ✓레코드를 읽고 저장하며 트랜잭션이 필요한 코드를 쓸 때.
  • ✓데이터베이스 연결을 설정하거나 마이그레이션이나 시드를 작성할 때.

스킬 링크

https://github.com/nocobase/nocobase/blob/v3-develop/packages/libs/db/skills/nocobase-db/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/nocobase/nocobase/blob/v3-develop/packages/libs/db/skills/nocobase-db/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“마이그레이션을 사용해, 고객과 연결된 주문 테이블을 제 NocoBase 앱에 추가해 주실 수 있나요?”

매주 새 스킬 5개. 읽는 데 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
라이선스
—
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬