Global

Methods

# after(opopt, handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute after specified database operations

Base decorator for handling post-operation behaviors

Parameters:
Name Type Attributes Default Description
op Array.<OperationKeys> | DBOperations <optional>
DBOperations.ALL

One or more operation types to handle

handler OperationHandler.<any, any, V, any, any>

The method called after the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 196

A decorator that can be applied to class properties

PropertyDecorator
Example
// Example usage:
class MyModel {
  

# afterAny(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute after any database operation

Decorator for handling post-operation for all operation types

Parameters:
Name Type Attributes Description
handler StandardOperationHandler.<any, any, V, any, any>

The method called after the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 183

A decorator that can be applied to class properties

PropertyDecorator

# afterCreate(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute after create operations

Decorator for handling post-create operations

Parameters:
Name Type Attributes Description
handler StandardOperationHandler.<any, any, V, any, any>

The method called after the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 144

A decorator that can be applied to class properties

PropertyDecorator

# afterCreateUpdate(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute after both create and update operations

Decorator for handling post-create and post-update operations

Parameters:
Name Type Attributes Description
handler StandardOperationHandler.<any, any, V, any, any> | UpdateOperationHandler.<any, any, V, any, any>

The method called after the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 118

A decorator that can be applied to class properties

PropertyDecorator

# afterDelete(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute after delete operations

Decorator for handling post-delete operations

Parameters:
Name Type Attributes Description
handler StandardOperationHandler.<any, any, V, any, any>

The method called after the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 170

A decorator that can be applied to class properties

PropertyDecorator

# afterRead(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute after read operations

Decorator for handling post-read operations

Parameters:
Name Type Attributes Description
handler StandardOperationHandler.<any, any, V, any, any>

The method called after the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 157

A decorator that can be applied to class properties

PropertyDecorator

# afterUpdate(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute after update operations

Decorator for handling post-update operations

Parameters:
Name Type Attributes Description
handler UpdateOperationHandler.<any, any, V, any, any>

The method called after the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 131

A decorator that can be applied to class properties

PropertyDecorator

# composed(args, separatoropt, hashopt, prefixopt, suffixopt) → {PropertyDecorator}

Decorator that generates a property value by joining the values of other properties

Creates a decorator that composes a property value from property values

Parameters:
Name Type Attributes Default Description
args Array.<string>

Property names whose values will be composed

separator string <optional>
DefaultSeparator

Character used to join the property values

hash boolean <optional>
false

Whether to hash the composed result

prefix string <optional>
""

Optional prefix to add to the composed value

suffix string <optional>
""

Optional suffix to add to the composed value

View Source model/decorators.ts, line 127

A decorator that can be applied to class properties

PropertyDecorator

# composedFrom(args, hashResultopt, separatoropt, typeopt, prefixopt, suffixopt) → {PropertyDecorator}

Base function for creating property composition decorators

Creates a decorator that composes a property value from other properties

Parameters:
Name Type Attributes Default Description
args Array.<string>

Property names to compose from

hashResult boolean <optional>
false

Whether to hash the composed result

separator string <optional>
DefaultSeparator

Character used to join the composed values

type "keys" | "values" <optional>
"values"

Whether to use property keys or values

prefix string <optional>
""

Optional prefix to add to the composed value

suffix string <optional>
""

Optional suffix to add to the composed value

View Source model/decorators.ts, line 82

A decorator that can be applied to class properties

PropertyDecorator

# composedFromKeys(args, separatoropt, hashopt, prefixopt, suffixopt) → {PropertyDecorator}

Decorator that generates a property value by joining the names of other properties

Creates a decorator that composes a property value from property keys

Parameters:
Name Type Attributes Default Description
args Array.<string>

Property names to compose from

separator string <optional>
DefaultSeparator

Character used to join the property names

hash boolean <optional>
false

Whether to hash the composed result

prefix string <optional>
""

Optional prefix to add to the composed value

suffix string <optional>
""

Optional suffix to add to the composed value

View Source model/decorators.ts, line 112

A decorator that can be applied to class properties

PropertyDecorator

# handle(op, handler) → {PropertyDecorator}

Registers an operation handler for a specific operation key on a target property

Internal function to register operation handlers

Parameters:
Name Type Description
op OperationKeys

The operation key to handle

handler OperationHandler.<any, any, any, any, any>

The handler function to register

View Source operations/decorators.ts, line 6

A decorator that registers the handler

PropertyDecorator

# hash() → {PropertyDecorator}

Decorator that automatically hashes a property value during create and update operations

Creates a decorator that hashes a property value

View Source model/decorators.ts, line 34

A decorator that can be applied to class properties

PropertyDecorator

# id() → {PropertyDecorator}

Creates a composite decorator that marks a property as required, readonly, and as the ID field for database operations

Decorator that marks a property as an ID field

View Source identity/decorators.ts, line 7

A decorator that can be applied to class properties

PropertyDecorator

# on(opopt, handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute during specified database operations

Base decorator for handling database operations

Parameters:
Name Type Attributes Default Description
op Array.<OperationKeys> | DBOperations <optional>
DBOperations.ALL

One or more operation types to handle

handler OperationHandler.<any, any, V, any, any>

The method called upon the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 98

A decorator that can be applied to class properties

PropertyDecorator
Example
// Example usage:
class MyModel {
  

# onAny(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute during any database operation

Decorator for handling all operation types

Parameters:
Name Type Attributes Description
handler OperationHandler.<any, any, V, any, any>

The method called upon the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 85

A decorator that can be applied to class properties

PropertyDecorator

# onCreate(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute during create operations

Decorator for handling create operations

Parameters:
Name Type Attributes Description
handler StandardOperationHandler.<any, any, V, any, any>

The method called upon the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 46

A decorator that can be applied to class properties

PropertyDecorator

# onCreateUpdate(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute during both create and update operations

Decorator for handling create and update operations

Parameters:
Name Type Attributes Description
handler StandardOperationHandler.<any, any, V, any, any> | UpdateOperationHandler.<any, any, V, any, any>

The method called upon the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 20

A decorator that can be applied to class properties

PropertyDecorator

# onDelete(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute during delete operations

Decorator for handling delete operations

Parameters:
Name Type Attributes Description
handler OperationHandler.<any, any, V, any, any>

The method called upon the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 72

A decorator that can be applied to class properties

PropertyDecorator

# onRead(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute during read operations

Decorator for handling read operations

Parameters:
Name Type Attributes Description
handler IdOperationHandler.<any, any, V, any, any>

The method called upon the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 59

A decorator that can be applied to class properties

PropertyDecorator

# onUpdate(handler, dataopt) → {PropertyDecorator}

Defines a behavior to execute during update operations

Decorator for handling update operations

Parameters:
Name Type Attributes Description
handler UpdateOperationHandler.<any, any, V, any>

The method called upon the operation

data V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 33

A decorator that can be applied to class properties

PropertyDecorator

# operation(baseOp, operationopt, handler, dataToAddopt) → {PropertyDecorator}

Creates decorators that register handlers for database operations

Core decorator factory for operation handlers

sequenceDiagram participant Client participant Decorator as @operation participant Operations as Operations Registry participant Handler Client->>Decorator: Apply to property Decorator->>Operations: Register handler Decorator->>Decorator: Store metadata Note over Client,Handler: Later, during operation execution Client->>Operations: Execute operation Operations->>Handler: Call registered handler Handler-->>Operations: Return result Operations-->>Client: Return final result
Parameters:
Name Type Attributes Default Description
baseOp OperationKeys.ON | OperationKeys.AFTER

Whether the handler runs during or after the operation

operation Array.<OperationKeys> <optional>
DBOperations.ALL

The specific operations to handle

handler OperationHandler.<any, any, V, any, any>

The handler function to execute

dataToAdd V <optional>

Optional metadata to pass to the handler

View Source operations/decorators.ts, line 216

A decorator that can be applied to class properties

PropertyDecorator

# readonly(messageopt) → {PropertyDecorator}

Marks the property as readonly, causing validation errors if attempts are made to modify it during updates.

Prevents a property from being modified after initial creation.

Parameters:
Name Type Attributes Description
message string <optional>

The error message to display when validation fails. Defaults to DEFAULT_ERROR_MESSAGES.READONLY.INVALID

View Source validation/decorators.ts, line 11

A decorator function that can be applied to class properties

PropertyDecorator

# serialize() → {PropertyDecorator}

Decorator that automatically converts complex objects to JSON strings before storing in the database and back to objects when retrieving them.

Enables automatic JSON serialization and deserialization for complex object properties.

sequenceDiagram participant C as Client participant M as Model participant S as SerializeDecorator participant DB as Database Note over C,DB: Create/Update Flow C->>M: Set complex object property M->>S: Process property (create/update) S->>M: Convert to JSON string M->>DB: Store serialized data Note over C,DB: Retrieval Flow C->>M: Request model M->>DB: Fetch data DB->>M: Return with serialized property M->>S: Process property (after all ops) S->>M: Parse JSON back to object M->>C: Return model with deserialized property

View Source validation/decorators.ts, line 163

A decorator function that can be applied to class properties

PropertyDecorator

# timestamp(operation, formatopt) → {PropertyDecorator}

Marks the property as a timestamp, making it required and ensuring it's a valid date. The property will be automatically updated with the current timestamp during specified operations.

Date Format:

     Using similar formatting as Moment.js, Class DateTimeFormatter (Java), and Class SimpleDateFormat (Java),
     I implemented a comprehensive solution formatDate(date, patternStr) where the code is easy to read and modify.
     You can display date, time, AM/PM, etc.

     Date and Time Patterns
     yy = 2-digit year; yyyy = full year
     M = digit month; MM = 2-digit month; MMM = short month name; MMMM = full month name
     EEEE = full weekday name; EEE = short weekday name
     d = digit day; dd = 2-digit day
     h = hours am/pm; hh = 2-digit hours am/pm; H = hours; HH = 2-digit hours
     m = minutes; mm = 2-digit minutes; aaa = AM/PM
     s = seconds; ss = 2-digit seconds
     S = miliseconds

Automatically manages timestamp properties for tracking creation and update times.

sequenceDiagram participant C as Client participant M as Model participant T as TimestampDecorator participant V as Validator C->>M: Create/Update model M->>T: Process timestamp property T->>M: Apply required validation T->>M: Apply date format validation alt Update operation T->>V: Register timestamp validator V->>M: Validate timestamp is newer end T->>M: Set current timestamp M->>C: Return updated model
Parameters:
Name Type Attributes Description
operation Array.<OperationKeys>

The operations to act on. Defaults to DBOperations.CREATE_UPDATE

format string <optional>

The timestamp format. Defaults to DEFAULT_TIMESTAMP_FORMAT

View Source validation/decorators.ts, line 46

A decorator function that can be applied to class properties

PropertyDecorator

# transient() → {PropertyDecorator}

Decorator that indicates a property should not be persisted to the database

Creates a decorator that marks a property as transient

View Source model/decorators.ts, line 201

A decorator that can be applied to class properties

PropertyDecorator

# version() → {PropertyDecorator}

This decorator applies multiple sub-decorators to handle version management during create and update operations

Creates a decorator for versioning a property in a model

View Source model/decorators.ts, line 191

A composite decorator that sets the type to Number, manages version updates, and adds versioning metadata

PropertyDecorator