/kavo-skills:mikroorm-adapterfrom Kavo Developer Skills
Wires Kavo into a NestJS app with MikroORM, passing the ORM instance instead of EntityManager. Covers case-insensitive filtering, soft delete, and cross-relation filtering.
Ships in Kavo Developer Skills. 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.
None: SKILL.md is the whole skill.
@kavo/mikroorm adapts Kavo to a MikroORM EntityManager. Setup is closest
to the TypeORM path — a decorated entity class is the identity, so nothing is
declared twice — with the differences below.
npm install @kavo/core @kavo/nest @kavo/mikroorm
@mikro-orm/core (^7.0.0) is a peer dependency, plus whichever driver
package your database needs (@mikro-orm/postgresql, @mikro-orm/mysql,
@mikro-orm/sqlite, …), and @mikro-orm/decorators if you declare entities
with decorators (below).
Decorators moved out of @mikro-orm/core in v7. They live in
@mikro-orm/decorators/legacy now; @mikro-orm/core still exports the
runtime pieces (MikroORM, Collection, wrap, …). Importing Entity from
@mikro-orm/core is the v6 spelling and no longer resolves.
// book.entity.ts
import { Entity, PrimaryKey, Property } from "@mikro-orm/decorators/legacy";
@Entity()
export class Book {
@PrimaryKey({ type: "number" })
id!: number;
@Property({ type: "string" })
title!: string;
}
@Kavo(Book)
@Controller("books")
export class BookController {}
// app.module.ts
import { Module } from "@nestjs/common";
import { KavoModule } from "@kavo/nest";
import { createInfrastructure } from "@kavo/mikroorm";
import { MikroORM } from "@mikro-orm/core";
import { defineConfig } from "@mikro-orm/postgresql";
import { Book } from "./book.entity.js";
import { BookController } from "./book.controller.js";
const orm = await MikroORM.init(defineConfig({ dbName: process.env.DB_NAME!, entities: [Book] }));
@Module({
imports: [
KavoModule.forRoot({
infrastructure: createInfrastructure(orm),
}),
],
controllers: [BookController],
})
export class AppModule {}
createInfrastructure takes the MikroORM instance, not an
EntityManager, on purpose. MikroORM is a Unit-of-Work ORM whose
EntityManager holds an identity map, so every Kavo operation calls
orm.em.fork() to get its own — the isolation a request-scoped
RequestContext would give a hand-written app.
You do not need RequestContext middleware for Kavo's routes. Adding it
is not required and buys nothing here.
filter[name][ilike]=ada% maps to MikroORM's $ilike, which only
PostgreSQL supports — every other driver receives the token verbatim and
fails with a syntax error. MikroORM exposes no way to detect this, so it is a
declared setting, defaulting to off:
createInfrastructure(orm, { caseInsensitiveFilters: true }); // PostgreSQL only
With it off, ilike behaves exactly like like. On SQLite that is not even
a loss — SQLite's own LIKE is already ASCII case-insensitive.
(Note this is the opposite default from @kavo/prisma, where the same
setting is on unless you turn it off.)
MikroORM has no @DeleteDateColumn equivalent — its soft-delete pattern is a
user-defined @Filter, which Kavo cannot detect. Add an ordinary property
and name it in config; that is what generates PATCH /books/:id/restore
(ADR-0013):
@Kavo(Book, { delete: { field: "deletedAt" } })
@Controller("books")
export class BookController {}
Do not also enable a MikroORM soft-delete @Filter. Kavo owns the
scoping, and a second default-on predicate quietly defeats withDeleted.
MikroORM nests relation paths in its own query language, so
filter[author.name][eq]=Ada needs no join bookkeeping — only an allowlist
entry, which is a separate decision from whether the relation may be
included:
@Kavo(Book, {
allowed: { filterable: ["title", "author.name"] },
relations: { edges: { author: { includable: true } } },
})
@Controller("books")
export class BookController {}
ESCAPE in like patterns depends on your driver. MikroORM cannot
attach an ESCAPE clause, so \ escaping a literal %/_ works on
PostgreSQL and MySQL (which default to backslash) but not on SQLite.@Property({ hidden: true }) beats a Kavo DTO. Rows are converted with
MikroORM's own toObject(), so a hidden property is gone before core sees
it — naming it in a DTO will not bring it back.kavo-decoratorfilter/sort/fields/include wire grammar → query-grammardto-slotssoft-deleteWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub kavo-labs/kavo --plugin kavo-skills15 skills in this plugin
/composite-primary-keysReference for composite primary key support in @kavo/typeorm — the compositeIdFields metadata field, the ~-delimited route-id encoding, the creatable/updatable split, and every place composite keys don't yet work (other ORM adapters, many-to-many array-mutation, @kavo/graphql). Use when an entity has more than one @PrimaryColumn, or when a route id, association, or array-mutation write on such an entity behaves unexpectedly./dto-slotsReference for Kavo's six optional schema slots (create/update/patch/query/item/list) — entity-derived defaults, the schemaShapeKeys narrowing rule, and serialization order. Use when configuring a DTO class or validator on @Kavo's schema option, or answering "why isn't my field showing/hiding" or "what shape does this response have" questions./error-handlingReference for Kavo's exception hierarchy, KAVO_* error-code catalog, and the RFC 9457 problem-details wire shape every generated route returns on failure. Use when handling/mapping a Kavo error, deciding which exception to throw from a custom handler/@Override, or answering "what does the error response look like" questions./global-configReference for Kavo's global configuration — the KavoSettings precedence chain, built-in defaults table, KavoModule.forRoot/forRootAsync options, and the operations.<id> global-default caveat (ADR-0015). Use when wiring createKavo/KavoModule.forRoot, setting app-wide defaults, or answering "what can I configure globally" questions./graphql-bindingReference for @kavo/graphql and its Nest binding — building a schema over an existing createCrud service, the raw-AST filter/sort args, multi-entity merging, the process-wide type registry, and the zero-code KavoModule graphql option. Use when exposing an entity over GraphQL, or answering "how do I add GraphQL to this entity" questions./kavo-decoratorReference for what @Kavo(Entity, config?) generates and how to configure/override it — routes table, EntityConfig shape (schema/allowed/operations), manual-method-wins, @Override, and fully custom routes. Use when writing or reviewing a @Kavo-decorated controller, or answering "how do I configure/override this route" questions.Other plugins' skills for the same job