SlintORM
Docsnpm

@omitdb / @omitjson / @omitmigrate

Three annotations that control whether a field is stored, serialized, or managed by the migrator.

Reference

AnnotationStored in DBReturned in readsManaged by migrator
@omitdbNo (excluded from INSERT SET, no column)NoN/A
@omitjsonYesNo (unless explicitly .select()ed)Yes
@omitmigrateDepends on manual DDLYesNo (skips column in CREATE/ALTER)

@omitdb — No Database Column

The field exists only at the type level. It's excluded from INSERT SET clauses and never stored. Useful for computed fields, transient data, or columns managed externally.

src/interfaces.ts
// @omitdb
internalNote?: string;  // TS-only field

const user = await User.insert({
  name: "Alice",
  internalNote: "secret",
});
console.log(user.internalNote); // undefined (excluded from insert)
// The column does NOT exist in the database table

@omitjson — Strip from Reads

The field IS stored in the database but stripped from all read results unless explicitly selected. Useful for internal audit data, system fields, or values only needed for backend processing.

src/interfaces.ts
// @omitjson
auditData?: string;  // stored but hidden from reads

const user = await User.insert({ name: "Alice", auditData: "created-by-admin" });
console.log(user.auditData); // undefined (stripped)

// Explicit .select() returns it:
const withAudit = await User.query()
  .select("name", "auditData")
  .where("name", "=", "Alice")
  .get();
console.log(withAudit[0].auditData); // "created-by-admin"

// Raw SQL confirms it's stored:
const raw = await orm.execRaw("SELECT auditData FROM users WHERE name = ?", ["Alice"]);
console.log(raw.rows[0].auditData); // "created-by-admin"

@omitmigrate — Skip Migrator

The migrator ignores this column during migrate() — it won't create, alter, or drop it. You manage the DDL manually. The field is still usable in queries.

src/interfaces.ts
// @omitmigrate
tempField?: string;  // manual DDL only

// After migrate(), no column exists for tempField.
// You must CREATE it manually:
await orm.execRaw("ALTER TABLE users ADD COLUMN tempField TEXT");

Errors

IssueCauseFix
@omitdb field visible in query resultMisconfiguration or cacheRegenerate schema and verify the annotation is on the correct field
@omitmigrate column created by migrate()The migrator version may not support @omitmigrateUpdate to SlintORM v1.5+

Conventions

See also