Decorators
@system-inc/base-foundation · 515c140 · 25 symbols
@InjectDatabase
Injects an OrmDatabase.
With no argument, resolution is module-aware: the database is the one
the injecting class's declared module resolves to (its databaseName
or the worker's database registration modifier). Membership is declared
with @Injectable(SomeModuleKey) or any other injectable-family
decorator; an undeclared class resolves to the default database — a
uniform contract in every worker. Registration in module settings never
routes injections (boot validation rejects a non-default-database
module's class that forgot to declare). Pass a DatabaseBinding or a
TypedInjectionKey whose registered value names a data context to select
one explicitly — an explicit token always wins.
@InjectRepository
Injects an OrmRepository bound to the given Entity.
The entity type flows through to the resolved
OrmRepository<EntityType>, so the parameter's declared type is
verified at lint time.
entityThe target entity for which you want to inject the repository.
tokenOptional database selector — pass a `DatabaseBinding` or a `TypedInjectionKey` whose registered value names the data context. If omitted, resolution is **module-aware**: the repository binds to the database the injecting class's **declared module** resolves to (its `databaseName` or the worker's `database` registration modifier). Membership is declared with `@Injectable(SomeModuleKey)` or any other injectable-family decorator; an undeclared class resolves to the default database — a uniform contract in every worker. Registration in module settings never routes injections (boot validation rejects a non-default-database module's class that forgot to declare). An explicit token always wins.
@OrmAfterDelete
Marks an entity method to run after the entity has been deleted.
@OrmAfterInsert
Marks an entity method to run after the entity has been inserted. The entity's changed-field set is reset before the listener runs.
@OrmAfterLoad
Marks an entity method to run after the entity has been hydrated from a database row — useful for computing derived fields. The entity starts with a clean changed-field set.
@OrmAfterUpdate
Marks an entity method to run after the entity has been updated. The entity's changed-field set is reset before the listener runs.
@OrmBeforeDelete
Marks an entity method to run just before the entity is deleted.
@OrmBeforeInsert
Marks an entity method to run just before the entity is inserted — the last chance to normalize or fill fields that persist with the insert.
@OrmBeforeUpdate
Marks an entity method to run just before the entity is updated. Fields changed here are persisted with the update.
@OrmColumn
Maps a property to a database column of the given kind.
The property must use the declare keyword — columns are backed by
tracking accessors installed at construction time, so entity instances
record their own changed fields for minimal partial updates.
Mode-bearing kinds (bigint, decimal, datetime) require an explicit
mode choosing the JavaScript representation — see OrmColumnType.
kindThe column type and its type-specific options.
optionsColumn options such as `nullable`, `unique`, or `default`.
@OrmColumnIndex
Convenience decorator to add an index on a single column. Can be used with or without a custom name.
nameOptional custom name for the index. If not provided, generates: idx_<tableName>_<propertyName>
@OrmColumnUnique
Convenience decorator to add a unique constraint on a single column. Can be used with or without a custom name.
nameOptional custom name for the unique constraint. If not provided, generates: unq_<tableName>_<propertyName>
@OrmColumnUniqueIndex
Convenience decorator to add a unique index on a single column. This is different from OrmColumnUnique which creates a unique constraint. Can be used with or without a custom name.
nameOptional custom name for the unique index. If not provided, generates: unq_idx_<tableName>_<propertyName>
@OrmCreateDateColumn
Marks a property as the row's creation timestamp, set automatically on insert and immutable afterwards — upserts never overwrite it.
optionsColumn options.
@OrmJoinColumn
Specifies a join column for a relation.
Used with @OrmManyToOne and @OrmOneToOne relations to configure the foreign key column.
@OrmManyToOne
Defines a many-to-one relation. Multiple instances of this entity can reference one instance of the target entity.
@OrmOneToMany
Defines a one-to-many relation. One instance of this entity can be referenced by multiple instances of the target entity.
@OrmOneToOne
Defines a one-to-one relation. One instance of this entity references exactly one instance of the target entity.
@OrmPrimaryAutoColumn
Marks a property as the table's auto-generated primary key.
With 'uuid' the key is a generated UUID string; with 'serial' it is an
auto-incremented integer (optionally sized).
strategyHow the key is generated: `'uuid'` or `'serial'`.
strategyThe `'serial'` strategy.
sizeThe integer size of the column.
@OrmPrimaryKey
Declares the table's composite primary key on the entity class.
A table's primary key is declared exactly once: either a single column
(@OrmPrimaryAutoColumn or a column with primaryKey: true) or this
decorator listing the key columns. Order matters — it defines the backing
index, so list the hot lookup path first. Conflicting declarations throw at
class definition time.
columnsThe property names composing the key, in index order.
optionsAdditional primary key options.
@OrmTable
Marks a class as a database entity backed by a table.
Register the entity in a module's (or the worker's) orm.entities; the
schema builder turns its decorated columns into the table definition, and
repositories for it are injected with @InjectRepository. Entities extend
OrmTrackingEntity (or OrmBaseEntity/OrmMutableBaseEntity) so instances
track their own changed fields.
nameThe table name. Defaults to the class name when omitted.
optionsAdditional table options.
@OrmTableIndex
Adds an index over the given columns to the entity's table, with an auto-generated name.
columnsThe columns to include in the index.
optionsAdditional index options.
nameCustom name for the index.
columnsThe columns to include in the index.
optionsAdditional index options.
@OrmTableUnique
Decorator to add a unique constraint to a table with auto-generated name.
columnsThe columns to include in the unique constraint
nameCustom name for the unique constraint
columnsThe columns to include in the unique constraint
@OrmTableUniqueIndex
Adds a unique index over the given columns to the entity's table, with an auto-generated name.
columnsThe columns to include in the unique index.
optionsAdditional index options.
nameCustom name for the unique index.
columnsThe columns to include in the unique index.
optionsAdditional index options.
@OrmUpdateDateColumn
Marks a property as the row's last-update timestamp, initialized to the creation time on insert and refreshed automatically on every update.
The column is non-nullable by default: a row that has never been updated is
one where updatedAt equals createdAt, not one where it is null.
optionsColumn options.