/mormot2-superpowers:mormot2-ormfrom mormot2-superpowers
Defines TOrm classes, builds TOrmModel schemas, maps field attributes, configures virtual tables, and performs ORM CRUD/batch operations via TRest descendants.
Ships in mormot2-superpowers. 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.
mORMot 2 ORM layer: declarative TOrm classes, TOrmModel schema definition, field attribute mapping, virtual tables, and CRUD/batch operations through TRest descendants. This skill is authoritative for the mormot.orm.* namespace and assumes the conventions defined in mormot2-core (RawUtf8 strings, custom RTTI, layered uses). Sibling skills extend this layer: mormot2-rest-soa exposes models over HTTP/REST, mormot2-db handles raw SQL when the ORM is the wrong tool.
TOrm descendant with typed published properties.TOrmModel from a list of TOrm classes (single or multi-database).stored AS_UNIQUE, index N, width M, default).TOrmVirtualTableJson, TOrmVirtualTableCsv, TOrmVirtualTableExternal).TRest.Add, TRest.Update, TRest.Retrieve, TRest.Delete.TRestBatch (insert/update/delete sequences with one round-trip commit).RawUtf8, TDocVariant), unit ordering, custom record RTTI. Use mormot2-core.Every persisted field is a published property with a mORMot-friendly type. RowID is implicit; do not declare it.
uses
mormot.core.base,
mormot.orm.core;
type
TOrmUser = class(TOrm)
private
fEmail: RawUtf8;
fRole: RawUtf8;
fLogon: TDateTime;
published
property Email: RawUtf8 read fEmail write fEmail;
property Role: RawUtf8 read fRole write fRole;
property Logon: TDateTime read fLogon write fLogon;
end;
A model is the schema. Pass it to the TRest (server or client). Free it during shutdown after the TRest is gone.
uses
mormot.orm.core;
var
Model: TOrmModel;
begin
Model := TOrmModel.Create([TOrmUser, TOrmRole, TOrmAuditLog]);
try
// pass Model to TRestServerDB.Create / TRestClientDB.Create
finally
Model.Free; // after the TRest is destroyed
end;
end;
stored AS_UNIQUE adds a SQL UNIQUE constraint; index N sets max length for RawUtf8 (SQL VARCHAR(N)). Both are declarative and read by the ORM at model-creation time.
type
TOrmUser = class(TOrm)
published
property Email: RawUtf8 index 120 read fEmail write fEmail
stored AS_UNIQUE; // SQL: VARCHAR(120) UNIQUE NOT NULL
property Slug: RawUtf8 index 64 read fSlug write fSlug;
end;
A virtual table maps a TOrm class to a non-SQLite backend (JSON file, CSV, external SQL connection). Register it on the model before opening the database.
uses
mormot.orm.core,
mormot.orm.storage;
var
Model: TOrmModel;
begin
Model := TOrmModel.Create([TOrmCsvRow]);
Model.VirtualTableRegister(TOrmCsvRow, TOrmVirtualTableJson); // or Csv / External
// ORM verbs (Retrieve, RetrieveListJson, Add) work transparently against the backend.
end;
TRestBatch queues operations and ships them in a single round trip. Use it for bulk imports, scheduled syncs, or any path that touches many rows.
uses
mormot.orm.core;
var
Batch: TRestBatch;
User: TOrmUser;
i: Integer;
begin
Batch := TRestBatch.Create(Server.Orm, TOrmUser, 1000);
try
User := TOrmUser.Create;
try
for i := 0 to High(Inputs) do
begin
User.Email := Inputs[i].Email;
User.Role := 'member';
Batch.Add(User, true);
end;
finally
User.Free;
end;
Server.Orm.BatchSend(Batch); // single commit
finally
Batch.Free;
end;
end;
published modifier. Properties under public or private are invisible to RTTI and the ORM ignores them silently. Symptom: column missing from generated SQL, no error.Group, Order, User, or Index may compile but blow up at first SELECT. Either rename the Pascal property or alias the SQL name.TOrm.ID directly. The ORM owns RowID. Set it only via Add (which assigns the new ID back) or Retrieve (which reads it). Never declare a published property ID either; TOrm already exposes it.string for persisted text fields. Switch to RawUtf8. string will compile but every read/write pays a UTF-16 round trip, and JSON serialization may corrupt non-ASCII. See mormot2-core for the RawUtf8 boundary rule.TOrmModel is owned by your code, not by the TRest. After Server.Free, call Model.Free. Free in the wrong order and you double-free or leak RTTI structures.Add with SendData=false then expecting the row to come back. SendData controls whether non-default fields are written. With false you get an empty row plus the new ID, not the values you set on the instance.$MORMOT2_DOC_PATH/mORMot2-SAD-Chapter-05.md - TOrm and TOrmModel$MORMOT2_DOC_PATH/mORMot2-SAD-Chapter-06.md - ORM Daily Patternsreferences/torm-cheatsheet.mdreferences/torm-model-patterns.mdreferences/virtual-tables.mdmormot2-core for RawUtf8 conventions and custom record RTTImormot2-db for non-ORM SQL accessmormot2-rest-soa for exposing the ORM as RESTWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub flydev-fr/mormot2-superpowers --plugin mormot2-superpowers24 skills in this plugin
/brainstormingYou MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation./delphi-buildUse when configuring Delphi builds: dcc32/dcc64 flags, .dproj search paths, MSBuild targets, conditional defines. Do NOT use for FPC/Lazarus (use fpc-build) or runtime config (use mormot2-deploy)./dispatching-parallel-agentsUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies/executing-plansUse when you have a written implementation plan to execute in a separate session with review checkpoints/finishing-a-development-branchUse when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup/fpc-buildUse for FPC/Lazarus builds: -Mobjfpc/-Sci modes, -Fu/-Fi search paths, .lpi files, lazbuild, cross-compilation, FPC_X64MM. Do NOT use for Delphi (delphi-build) or runtime config (mormot2-deploy).Other plugins' skills for the same job