Nestjs Dataのロゴ

Nestjs Data

組織
nestjs
nestjs-data

Databases in a NestJS application with the first-party @nestjs/drizzle and @nestjs/typeorm integrations - registering the database, injecting it into services, schemas or entities, migrations, transactions, and writes that stay correct under concurrent requests. Use when adding or changing persistence in a NestJS application.

概要

公開者nestjs
リポジトリagent-skills
スキル名nestjs-data
スター
176
フォーク
5
同梱ファイル
1
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 1個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    nestjsがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Nestjs Data」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/nestjs/agent-skills/tree/master/plugins/nestjs/skills/nestjs-data
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/nestjs/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/plugins/nestjs/skills/nestjs-data .claude/skills/nestjs-data
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでNestjs Dataを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にNestjs Dataを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Nestjs Dataは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Persistence in a NestJS app

Nest integrates the common ORMs; pick one per app and keep queries in services or repositories, not controllers.

PackageDocs
Drizzle (SQL-like, schema in TypeScript, no classes)@nestjs/drizzle + drizzle-orm@rc (v1)https://docs.nestjs.com/data/drizzle.md
TypeORM (entity classes, repositories)@nestjs/typeorm + typeormhttps://docs.nestjs.com/data/typeorm.md
Prisma, MongoDB (Mongoose), Sequelize, MikroORM/data/prisma, /data/mongodb, ...

If the project already uses one, keep it.

Drizzle

typescript
DrizzleModule.forRoot({ drizzle, connection }) // drizzle(): your driver's, e.g. from 'drizzle-orm/libsql'

then @InjectDrizzle() private readonly db: LibSQLDatabase (type from the driver's entry point) in any provider; no forFeature(). The client closes on app.close()/shutdown hooks. Tables are plain objects: sqliteTable('notes', {...}), types from $inferSelect/$inferInsert. Migrations: drizzle-kit generate then drizzle-kit migrate, or migrate() from the driver's /migrator at startup.

TypeORM

TypeOrmModule.forRoot({ type, database, autoLoadEntities: true, synchronize: false }) at the root, TypeOrmModule.forFeature([Note]) in the feature module, @InjectRepository(Note) private readonly notes: Repository<Note>. synchronize: true is for throwaway development databases only: it can drop columns and data. Use migrations otherwise.

Rules

  • Don't read, then save() a whole entity to update it. TypeORM's save() inserts the row if it's gone, so a PATCH that loaded a note just before a concurrent DELETE puts it back. Update with repo.update({ id, userId }, changes) (or a query builder) and check result.affected; delete with repo.delete({ id, userId }). With Drizzle, db.update(notes).set(changes).where(and(eq(notes.id, id), eq(notes.userId, userId))).returning() and treat no row as 404.
  • Scope by owner in the query, not after loading: where: { id, userId: user.id }. A row that isn't the caller's is then simply not found.
  • Map constraint violations, don't pre-check. Insert and catch the unique violation (Drizzle wraps the driver's error: walk error.cause; SQLite SQLITE_CONSTRAINT_UNIQUE, PostgreSQL 23505) and answer 409; a lookup first lets two concurrent requests both pass.
  • Page with a cursor (WHERE id > :after ORDER BY id LIMIT :limit + 1), not OFFSET: no COUNT(*), stable under inserts.
  • Check-then-write in one statement or a transaction. "Is the email taken? then insert" needs a unique index (catch the violation and answer 409); "count admins, then demote" needs a transaction (Drizzle db.transaction(async (tx) => ...), TypeORM dataSource.transaction(async (manager) => ...)).
  • Cascades in the schema: onDelete: 'cascade' on the foreign key (Drizzle references(() => users.id, { onDelete: 'cascade' }), TypeORM @ManyToOne(() => User, { onDelete: 'CASCADE' })), and for SQLite turn foreign keys on (PRAGMA foreign_keys = ON).
  • Data that must survive a restart lives in a file or server database from the configured path or URL, never :memory:. Create the parent directory if needed.
  • Numbers that come back as strings. PostgreSQL bigint (int8) and numeric/decimal arrive as strings through pg, because JavaScript numbers can't hold them exactly. Convert where you need arithmetic, choose the column mode on purpose (Drizzle bigint({ mode: 'number' }) only when values stay below 2^53), and keep money as integer cents or numeric handled as strings.
  • Times in UTC. Store timestamps in UTC (timestamptz in PostgreSQL; epoch milliseconds or ISO strings in SQLite, which has no date type) and convert at the edges.
  • Short transactions. Never await an HTTP call, a queue or a user inside a transaction: it holds a pooled connection (and locks) the whole time, and a slow third party then exhausts the pool. Call out before or after, or use an outbox (@nestjs/outbox).
  • One Prisma client. With Prisma, create one PrismaService extends PrismaClient provider, exported from one module, not a new PrismaClient() per service: each client has its own connection pool.
  • Async drivers yield between statements: two requests can interleave between a read and a write. Synchronous drivers (better-sqlite3) don't, which hides races in tests that would appear on PostgreSQL.

Recipes, all run on the released packages: schemas and relations, migrations at startup or as a release step, a repository with owner-scoped queries, cursor paging and unique violations mapped to 409, transactions, testing: references/data.md.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Nestjs Data」では何ができますか?

Databases in a NestJS application with the first-party @nestjs/drizzle and @nestjs/typeorm integrations - registering the database, injecting it into services, schemas or entities, migrations, transactions, and writes that stay correct under concurrent requests. Use when adding or changing persistence in a NestJS application.

TypingMindでNestjs Dataを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Nestjs Dataはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにNestjs Dataをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/nestjs/agent-skills/tree/master/plugins/nestjs/skills/nestjs-dataを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Nestjs Dataを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Nestjs Dataで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもNestjs Dataを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Nestjs Data」は無料ですか?

はい。nestjsがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇