Nestjs Data logo

Nestjs Data

Organization
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.

Overview

Publishernestjs
Repositoryagent-skills
Skill namenestjs-data
Stars
176
Forks
5
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by nestjs on GitHub. Read the source before you install it.

Installation

Install the Nestjs Data AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/nestjs/agent-skills/tree/master/plugins/nestjs/skills/nestjs-data
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Nestjs Data in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Nestjs Data on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Nestjs Data is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Nestjs Data AI skill do?

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.

Why use Nestjs Data on TypingMind?

Because you install it once and use it with any model. Nestjs Data is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Nestjs Data in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/nestjs/agent-skills/tree/master/plugins/nestjs/skills/nestjs-data. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Nestjs Data?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Nestjs Data?

As many as you like. As long as a model supports skills, you can use Nestjs Data with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Nestjs Data AI skill free?

Yes. It is published on GitHub by nestjs under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇