Release Notes
All @datrix/* packages are released together and, since 0.3.0, share one version number. Install matching versions; each package requires @datrix/core of the same minor version or newer.
0.3.1
2026-11-22
A typing release: no runtime behavior changes. Queries that compiled but failed at runtime are now type errors.
Upgrading
- Run
datrix generate typesagain. Typedcreate/updatecalls with the generated input types (create<Post, CreatePostInput>(...)) failed to compile before (see cli below). - Fix the new type errors. Each one marks a query that already threw at runtime, such as a relation in
selector a scalar field inpopulate.
core
- Fixed: scalar fields typed as relations in WHERE. A field whose type matched the id type (a
stringfield in uuid mode, anumberfield in int mode) was taken for a relation and required a nested WHERE:where: { email: "[email protected]" }failed in uuid mode, andwhere: { views: 5 }failed in int mode. - Fixed: untyped calls lost their result type. Without a generic, a call that passed a WHERE or options inferred its model type from that argument, so
(await datrix.findOne("post", { slug })).titledid not compile. Untyped calls now always returnDatrixRecord, ondatrixand ondatrix.raw. - Typed field lists match what the query builder accepts.
With a model type (findMany<Post>(...)):
| Option | Accepts |
|---|---|
select, orderBy, groupBy, upsert conflictOn / update | scalar fields only (including id, createdAt, updatedAt) |
populate | relation fields only |
populate dot notation ("posts.comments") | now type-checks; the first two segments are checked against the relations |
orderBy inside populate options | every orderBy form, checked against the related model |
datrix.findMany<Post>("post", {
select: ["title", "views"], // ✅
populate: ["author", "comments.post"], // ✅
orderBy: ["-views"], // ✅
});
datrix.findMany<Post>("post", { select: ["author"] }); // ❌ relations are populated
datrix.findMany<Post>("post", { populate: ["title"] }); // ❌ not a relation
Untyped calls (no generic) keep accepting any field name.
- New helper types:
ScalarFieldKeys<T>,RelationFieldKeys<T>,RelatedEntity<V>andScalarFieldList<T>.
cli
datrix generate typesemitsXRelationUpdateas atypeinstead of aninterface, soCreateXInput/UpdateXInputwork as the input type ofcreate/update.
0.3.0
2026-11-22
Upgrading
- Node.js 22 or later is required by every package (
engines.node >= 22). - Existing projects keep integer ids.
idTypedefaults to"int", which produces the same schema as 0.2, so no migration diff appears. - On PostgreSQL the next
datrix migratechanges the authrolecolumn fromTEXTtoVARCHAR(64). This happens once (see api below).
uuid ids
- New
idType: "int" | "uuid"config option. In uuid mode every user schema'sid, foreign keys and junction columns are uuids. Core generates UUID v7 ids before insert, never the database. Internal_datrixschemas always keep integer ids. - UUID v7 ids are monotonic within the same millisecond, so ordering by
idfollows insertion order. - New
DatrixIdtype:number, orstringoncedatrix generate typesemits theDatrixRegisteraugmentation in uuid mode.DatrixEntry.id, relation references,findById/update/deleteandQueryContext.createdIdsuse it. - New
uuidfield type (canonical lowercase). Relation id shortcuts accept integer or uuid ids; the query builder canonicalizes them per target schema and rejects ids of the wrong kind. - New
parseIdParam(segment, schema)helper for parsing ids from URL segments. - Switching
idTypeon an existing database is a dedicated migration: export, rewrite of ids, foreign keys and junction rows, then import.datrix migratewrites a zip backup and an old → new id mapping file first, and it refuses to combine the switch with other schema changes. See Changing idType.
core
- Schema defaults are applied before validation. On create (
create,createMany, nested relation creates, raw mode, and the insert path ofupsert), fields you did not provide get theirdefault. Before this release arequiredfield with adefaultwas rejected as missing.- Only
undefinedis filled: an explicitnullis kept. - Updates, including the conflict path of
upsert, never re-apply defaults. - Defaults are validated like any other value.
- Only
- Function defaults (
default: () => value) are called once per row; before, they were silently dropped. Object and array defaults are cloned per row.
Adapters
All adapters support uuid ids:
| Adapter | uuid ids map to |
|---|---|
| PostgreSQL | UUID (kept from RETURNING) |
| MySQL / MariaDB | CHAR(36) (read from the data instead of insertId) |
| MongoDB | string (no id counters) |
| JSON | string (no auto-increment counter) |
- Import skips the sequence, auto-increment or counter reset for uuid tables.
- mysql: fixed object and array
defaultvalues on JSON columns failing on MariaDB. They render as a JSON string literal, which works on MySQL 8.0.13+ and MariaDB 10.2+. - postgres: fixed import failing on tables with mixed-case names, such as junction tables.
api
- Route ids follow the schema's id type; malformed ids return 404. Authentication, email sync, and the JWT and session guards accept uuid user ids.
- The auth
rolefield hasmaxLength: 64and maps toVARCHAR(64). Before this, auth could not be migrated on MySQL or MariaDB, because they rejectDEFAULTonTEXTcolumns. Role names longer than 64 characters are rejected. - api-upload:
DELETE /upload/:idaccepts uuid ids.
cli
generate typesemits theDatrixRegisteraugmentation in uuid mode and types uuid fields asstring.- Fixed file import resolving record ids with
Number(), which broke media relinking for uuid ids.
0.2.2
2026-10-19 — @datrix/core 0.2.2, adapters and api 0.2.1
- Upsert:
upsert(model, data, { conflictOn, update? })andupsertMany(...)ondatrix,datrix.rawandtx.conflictOnmust be a unique field or the fields of a unique index;updatelimits the overwritten fields. Each adapter implements it natively (PostgreSQLON CONFLICT, MySQLON DUPLICATE KEY UPDATE, MongoDBbulkWrite). - New
beforeUpsert/afterUpsertschema hooks;afterUpsertreceives the records split intocreated/updated. - New
QueryContext.createdIds: the ids a create or upsert inserted, set before after-hooks run. - api: authentication records are created for upserted users.
0.2.1
2026-10-18
- Transactions:
datrix.transaction(fn, options?)commits whenfnresolves and rolls back when it throws.tx.rollback()rolls back on purpose, andtx.afterCommit()defers side effects until commit. See Transactions. - New
context.crudin hooks: queries made from a hook join the caller's transaction.
0.2.0
2026-07-18
A hardening release across every package.
- core: the query builder validates
orderBy,groupByandhaving, rejectsUPDATEwithout a WHERE, and stops coercing bad ids toNaNor0. NewcountMany,groupBy,havinganddistinctquery API. Fixes for self-referential relations, migration diff false positives and validator edge cases. - Adapters: fixes for
$icontainsand LIKE escaping, COUNT with relation joins, and connection leaks in transactions. Per-relationlimit/offsetin populate. Export and import are scoped to tables Datrix manages, and import is atomic. - api (breaking):
- JWT signatures are standard
base64url, so previously issued tokens are invalidated. create/update/deleterequire an authenticated user by default.- New
QUERYmethod (POST /api/:schema/query) takes a JSON query body. - Security fixes: no password hash in
/auth/me, no mass assignment on register, per-request identity isolation.
- JWT signatures are standard
- api-upload (breaking): uploads require authentication and permission checks; image types are verified against the file content.
- cli: new
datrix generate config, offlinegenerate types, and--version/--yes/--forceflags. Fixes for CSV and zip data integrity. - Internal dependencies use
workspace:^.
0.1.2
2026-04-12
- api: password reset flow (
POST /auth/forgot-password,POST /auth/reset-password,passwordReset.onForgotPassword);AuthConfigtakes aTUsergeneric for typed user population. - core: optional scalar fields no longer resolve to
neverin typed WHERE clauses.
0.1.1 — Initial release
2026-04-07
First public release of the @datrix/* packages: core, the PostgreSQL, MySQL, MongoDB and JSON adapters, api, api-upload and cli.