/engineering-paved-path:typeorm-patternsfrom engineering-paved-path
TypeORM patterns for PostgreSQL-backed TypeScript services — entity and relation definition, DataSource configuration, repository vs EntityManager, QueryBuilder versus find semantics, raw-SQL escape hatches and their result shapes, hand-written migration discipline, transactions and query runners, soft deletes, and the indexes and constraints TypeORM can express at the entity boundary. Use when defining or changing an entity, writing or reviewing a query, generating or hand-writing a migration, wrapping work in a transaction, debugging a result that came back in an unexpected shape, adding a soft-deletable table, or upgrading TypeORM. Trigger terms: TypeORM, DataSource, Repository, EntityManager, createQueryBuilder, getRepository, @Entity, @Column, @ManyToOne, @DeleteDateColumn, migration:generate, migration:run, softDelete, withDeleted, QueryRunner, upsert, node-postgres, pg. TypeORM mechanics ONLY — NOT NestJS module wiring or provider injection (use engineering-paved-path:nestjs-best-practices), NOT PostgreSQL table and index design (use engineering-paved-path:postgresql-table-design), NOT where a repository file belongs in the layering (use engineering-paved-path:onion-architecture).
Trending skills
7-day visitors to each skill page
Ships in engineering-paved-path. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
What TypeORM actually does, where it differs from what its API suggests, and which behaviours are undocumented and must be pinned by a test. ORM mechanics only — not Nest wiring (engineering-paved-path:nestjs-best-practices), not schema design (engineering-paved-path:postgresql-table-design), not layering (engineering-paved-path:onion-architecture).
PostgreSQL, via the pg driver. TypeORM supports other databases and most
of the layering advice here survives them, but a great deal of this skill does
not: raw-SQL result shapes, $1 parameter syntax, enum semantics, RETURNING,
cardinality(), index types, CREATE INDEX CONCURRENTLY, and the
node-postgres type-parsing behaviour are all PostgreSQL-and-pg specific.
On MySQL, SQLite, MSSQL or MongoDB, treat every one of those as unverified and
check the driver's own documentation. What does transfer: the
save/insert/upsert/update trade-offs, take/skip vs
limit/offset, eager relations being ignored by QueryBuilder, soft-delete
filtering, the transaction-manager discipline, and migration review.
This skill assumes nothing about your repository beyond what you tell it. When applying it, first locate (or ask for): the DataSource definition, the entity directory, the migrations directory and its naming convention, the migration commands, the database-backed test command and how it gets a database. If the project documents its own rules — hand-written migrations only, a particular transaction wrapper, a repository convention — those take precedence over anything here.
Read the installed version out of the lockfile before applying anything on this page. TypeORM 1.x is the current line and is recent, so "TypeORM is 0.3.x" as a working assumption is out of date — but 0.3.x is still maintained and still widely deployed, and the two lines differ in ways that change query results rather than raising errors. Treat every 1.x-specific claim below as inapplicable until you have confirmed the major.
If the project is on 0.3.x, read references/upgrading-from-0.3.md as a difference list, not an upgrade plan: everything it says changed in 1.0 is a statement about what your code does today. In particular, on 0.3.x null/undefined in a where are silently ignored rather than throwing, non-nullable relations LEFT JOIN rather than INNER JOIN, the global helpers (getRepository, getManager, createConnection) still exist, and string-array select/relations still work.
| Fact | Value |
|---|---|
| Current | 1.1.1, released 2026-09-01. 1.1.0 → 2026-07-13; 1.0.0 → 2026-05-19 |
| 0.3.x | still patched (0.3.31), marked legacy on the docs version selector |
| Node.js | ^20.19.0 || ^22.13.0 || >=24.11.0; compiled to ES2023 — Node 16/18 dropped |
| PostgreSQL driver | peer dependency pg@^8.5.1 — the pg 8.x line |
| With NestJS | @nestjs/typeorm ≥ 11.0.1 is required for TypeORM 1.x; v10 and v11.0.0 crash at startup because they still register the removed Connection class. Current is 12.0.x |
| Upgrade aid | npx @typeorm/codemod v1 src/ |
1.0 was the first breaking release in about five years. references/upgrading-from-0.3.md has the full list; the four changes most likely to alter behaviour silently — all four are 1.x-only, and on 0.3.x the pre-change behaviour in each is what you have:
invalidWhereValuesBehavior defaults to "throw" in 1.x. null/undefined in a where were silently ignored on 0.3.x; on 1.x they throw. Use IsNull(), or opt back in explicitly.INNER JOIN in 1.x, LEFT JOIN on 0.3.x. Rows are silently excluded on 1.x where 0.3.x returned them with a null relation.orphanedRowAction: "nullify" against a non-nullable FK deletes the orphan in 1.x; on 0.3.x it throws a constraint violation.getRepository(), getManager(), createConnection(), getConnection() and the rest. On 0.3.x they still exist; hold a DataSource and pass it anyway, because that is the shape that survives the upgrade.Valid on both lines unless a row says otherwise.
| Operation | Call | Note |
|---|---|---|
| Read one | repo.findOneBy({ id }) | excludes soft-deleted roots |
| Read many | repo.find({ where, relations, take, skip }) | object syntax for relations/select — required on 1.x, accepted on 0.3.x, so write it this way on both |
| Insert | repo.insert(values) | no SELECT, no cascades, no lifecycle hooks |
| Insert-or-update | repo.upsert(values, { conflictPaths }) | needs a unique constraint on the conflict target |
| Persist an entity | repo.save(entity) | SELECTs first, cascades, runs subscribers |
| Update by condition | repo.update(where, patch) | no entity load, no subscribers |
| Soft delete by condition | repo.softDelete(where) | sets @DeleteDateColumn |
| Soft delete an entity | repo.softRemove(entity) | cascades like remove() |
| Complex query | repo.createQueryBuilder('x') | ignores eager relations and soft-delete on the root |
| Raw SQL | dataSource.query(sql, params) | $1 placeholders; result shape varies by statement — see below |
| Transaction | dataSource.transaction(async (m) => …) | use m, never the global manager |
dataSource.query()'s result shape depends on the statement kind and is not documented. Getting it wrong fails silently or throws inside someone else's transaction → references/raw-sql.md.createQueryBuilder does not apply the soft-delete filter to the root entity — only find* does → references/soft-deletes.md.take/skip and limit/offset are not synonyms once a join is involved → references/query-builder.md.ON DELETE CASCADE never fires. Cascades on a soft-deleted parent are decorative → references/soft-deletes.md.DataSource options, initialisation, pooling, multiple data sources@RelationIdsave vs insert vs upsert vs update, find options, repository vs EntityManagertake/skip, joins, getMany vs getRawMany, subqueries, lockingquery() result shapes, parameterisation, what raw SQL bypassestransaction(), QueryRunner, isolation, propagating the manager@DeleteDateColumn, which paths filter and which do not, erasure@Index/@Unique can express, and when to drop to SQLpg type parsing, enums, CONCURRENTLY, pooling trapssynchronize: false. TypeORM's own words: "it is unsafe to use synchronize: true for schema synchronization on production once you get data in your database."typeorm — see engineering-paved-path:onion-architecture.UPDATE … WHERE … RETURNING makes the database the arbiter; a read followed by a write is a race with extra steps.README.md (opens in a new tab)references/data-source.md (opens in a new tab)references/entities-and-relations.md (opens in a new tab)references/indexes-and-constraints.md (opens in a new tab)references/migrations.md (opens in a new tab)references/postgres-specifics.md (opens in a new tab)references/query-builder.md (opens in a new tab)references/raw-sql.md (opens in a new tab)references/repository-api.md (opens in a new tab)references/soft-deletes.md (opens in a new tab)references/transactions.md (opens in a new tab)references/upgrading-from-0.3.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub yamchinsky/dev-digest-ai-marketplace --plugin engineering-paved-path12 skills in this plugin
/frontend-architectureFolder structure and code organization for React + Next.js (App Router) projects. Use this skill whenever the user asks where files should live (components, hooks, utils, helpers, lib, services, constants, types), how to break a component into smaller pieces, how to organize a feature folder, where to put business logic, when to use a barrel index, or how to lay out app/ in Next.js (route groups, private folders). Trigger on phrases like 'folder structure', 'project structure', 'where should I put', 'how to organize', 'where do constants go', 'utils vs helpers', 'app router structure'. Covers organization decisions only — NOT React hook rules or render patterns (use engineering-paved-path:react-best-practices) and NOT Next-specific runtime behavior (use engineering-paved-path:next-best-practices)./mermaid-diagramCreate Mermaid diagrams in markdown. Use when the user wants to visualize workflows, architectures, API flows, data models, state machines, or system designs. Covers flowcharts, sequence diagrams, class diagrams, ER diagrams, state diagrams, and more./nestjs-best-practicesNestJS application patterns for TypeScript backends — modules and providers, dependency injection and injection tokens, the composition root, thin controllers, guards/interceptors/pipes/filters and their execution order, validation at the edge, ConfigModule and typed configuration, lifecycle hooks, exception filters, and testing with Test.createTestingModule. Use when building, wiring, reviewing or debugging a NestJS application: adding a module or a provider, resolving 'Nest can't resolve dependencies of X', choosing an injection scope, registering a global guard, shaping an error response, writing a testing module, or upgrading a NestJS major. Trigger terms: NestJS, Nest, @nestjs/common, @nestjs/core, app.module.ts, @Module, @Injectable, @Controller, provider, injection token, forwardRef, ValidationPipe, exception filter, APP_GUARD, Test.createTestingModule, nest build, nest start. NestJS runtime and wiring ONLY — NOT which layer a file belongs to (use engineering-paved-path:onion-architecture), NOT TypeORM query, migration or entity mechanics (use engineering-paved-path:typeorm-patterns), NOT PostgreSQL schema design (use engineering-paved-path:postgresql-table-design), NOT Zod schema mechanics (use engineering-paved-path:zod)./next-best-practicesNext.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling/onion-architectureLayering and dependency-rule conventions for TypeScript backends, with an optional pure-engine package. Use whenever editing or adding backend code; whenever adding a new module / use case / repository / adapter / outbound port / shared contract; whenever the question is *where should this live* on the backend (HTTP edge vs service vs repository vs adapter vs platform vs shared); whenever reviewing a backend PR for layer violations (ORM in a service, SDK import in a controller, `process.env` in a pure engine package, services importing other modules' services, SDK imports leaking past the adapter boundary). Trigger phrases: 'new endpoint', 'new module', 'where should this go', 'add a repository', 'add an adapter', 'wire up a port', 'consume X from a service', 'the engine needs to read', 'service is doing too much'. Layering and dependency placement ONLY — NOT NestJS runtime and wiring mechanics (use engineering-paved-path:nestjs-best-practices), NOT TypeORM query and migration mechanics (use engineering-paved-path:typeorm-patterns), NOT Zod schema mechanics (use engineering-paved-path:zod). For the client side use engineering-paved-path:frontend-architecture./postgresql-table-designUse this skill when designing or reviewing a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced featuresOther plugins' skills for the same job