Global

Methods

# column(columnName) → {function}

Decorator that maps a model property to a specific column name in the database

Specifies the database column name for a model property

Parameters:
Name Type Description
columnName string

The name of the column in the database

View Source model/decorators.ts, line 23

A decorator function that can be applied to a class property

function

# createdBy() → {function}

Decorator that marks a property to store the identifier of the user who created the model instance

Tracks the creator of a model instance

View Source model/decorators.ts, line 121

A decorator function that can be applied to a class property

function
Example
```typescript
class Document extends BaseModel {
  

# final() → {function}

This decorator prevents a method from being overridden by making it non-configurable. It throws an error if used on anything other than a method.

Creates a decorator that makes a method non-configurable

View Source utils/decorators.ts, line 2

A decorator function that can be applied to methods

function

# index(directionsopt, compositionsopt) → {function}

Decorator that marks a property to be indexed in the database, optionally with specific directions and compositions

Creates an index on a model property for improved query performance

Parameters:
Name Type Attributes Description
directions Array.<OrderDirection> <optional>

Optional array of sort directions for the index

compositions Array.<string> <optional>

Optional array of property names to create a composite index

View Source model/decorators.ts, line 34

A decorator function that can be applied to a class property

function

# manyToOne(clazz, cascadeOptionsopt, populateopt) → {function}

Decorator that establishes a many-to-one relationship between multiple instances of the current model and another model

Defines a many-to-one relationship between models

Parameters:
Name Type Attributes Default Description
clazz Constructor.<M>

The constructor of the related model class

cascadeOptions CascadeMetadata <optional>
DefaultCascade

Options for cascading operations (create, update, delete)

populate boolean <optional>
true

If true, automatically populates the relationship when the model is retrieved

See:

View Source model/decorators.ts, line 240

A decorator function that can be applied to a class property

function
Example
```typescript
class Book extends BaseModel {
  

# oneToMany(clazz, cascadeOptionsopt, populateopt) → {function}

Decorator that establishes a one-to-many relationship between the current model and multiple instances of another model

Defines a one-to-many relationship between models

Parameters:
Name Type Attributes Default Description
clazz Constructor.<M>

The constructor of the related model class

cascadeOptions CascadeMetadata <optional>
DefaultCascade

Options for cascading operations (create, update, delete)

populate boolean <optional>
true

If true, automatically populates the relationship when the model is retrieved

See:

View Source model/decorators.ts, line 198

A decorator function that can be applied to a class property

function
Example
```typescript
class Author extends BaseModel {
  

# oneToOne(clazz, cascadeOptionsopt, populateopt) → {function}

Decorator that establishes a one-to-one relationship between the current model and another model

Defines a one-to-one relationship between models

Parameters:
Name Type Attributes Default Description
clazz Constructor.<M>

The constructor of the related model class

cascadeOptions CascadeMetadata <optional>
DefaultCascade

Options for cascading operations (create, update, delete)

populate boolean <optional>
true

If true, automatically populates the relationship when the model is retrieved

See:

View Source model/decorators.ts, line 161

A decorator function that can be applied to a class property

function
Example
```typescript
class User extends BaseModel {
  

# pk(opts) → {PropertyDecorator}

Marks a property as the model's primary key with automatic sequence generation This decorator combines multiple behaviors: it marks the property as unique, required, and ensures the index is created properly according to the provided sequence options.

Primary Key Decorator

Parameters:
Name Type Description
opts Omit.<SequenceOptions, ("cycle"|"startWith"|"incrementBy")>

Options for the sequence generation

View Source identity/decorators.ts, line 69

A property decorator that can be applied to model properties

PropertyDecorator
Example
```typescript
class User extends BaseModel {
  

# pkOnCreate(context, data, key, model) → {Promise.<void>}

Handles the creation of primary key values for models using sequences

Callback function for primary key creation

sequenceDiagram participant Model participant pkOnCreate participant Adapter participant Sequence Model->>pkOnCreate: Call with model instance Note over pkOnCreate: Check if key already exists alt Key exists or no type specified pkOnCreate-->>Model: Return early else Key needs to be created pkOnCreate->>pkOnCreate: Generate sequence name if not provided pkOnCreate->>Adapter: Request Sequence(data) Adapter->>Sequence: Create sequence Sequence-->>pkOnCreate: Return sequence pkOnCreate->>Sequence: Call next() Sequence-->>pkOnCreate: Return next value pkOnCreate->>Model: Set primary key value end
Parameters:
Name Type Description
context Context.<F>

The execution context

data V

The sequence options

key

The property key to set as primary key

model M

The model instance

View Source identity/decorators.ts, line 9

A promise that resolves when the primary key is set

Promise.<void>

# repository(model, nameOverrideopt) → {any}

Creates and registers a repository for a model class. Can be used as both a property decorator and a class decorator.

Repository decorator for model classes.

sequenceDiagram participant C as Client Code participant D as Decorator participant R as Repository participant M as Metadata C->>D: Apply @repository(Model) alt Property Decorator D->>D: Check if propertyKey exists D->>+C: Return inject(name) decorator else Class Decorator D->>M: Set repository metadata on model D->>R: Register model with Repository D->>+C: Return injectable decorator with config C->>C: Define DBKeys.CLASS property end
Parameters:
Name Type Attributes Description
model Constructor.<T>

The constructor of the model class.

nameOverride string <optional>

Optional name override for the repository.

View Source repository/decorators.ts, line 6

  • The decorator function.
any

# table(tableName) → {function}

Decorator that sets the table name for a model class in the database

Specifies the database table name for a model

Parameters:
Name Type Description
tableName string

The name of the table in the database

View Source model/decorators.ts, line 12

A decorator function that can be applied to a class

function

# unique() → {function}

Decorator that ensures a property value is unique across all instances of a model in the database

Tags a property as unique

View Source model/decorators.ts, line 75

A decorator function that can be applied to a class property

function
Example
```typescript
class User extends BaseModel {
  

# updatedBy() → {function}

Decorator that marks a property to store the identifier of the user who last updated the model instance

Tracks the last updater of a model instance

View Source model/decorators.ts, line 141

A decorator function that can be applied to a class property

function
Example
```typescript
class Document extends BaseModel {
  

# uses(flavour) → {function}

This decorator applies metadata to a model class to indicate which persistence adapter flavor should be used when performing database operations on instances of the model. The flavor is a string identifier that corresponds to a registered adapter configuration.

Specifies which persistence adapter flavor a model should use

Parameters:
Name Type Description
flavour string

The identifier of the adapter flavor to use

View Source persistence/decorators.ts, line 5

A decorator function that can be applied to a model class

function