Skip to main content

Model

Callable

  • Model<T>(packageName: string, modelName: string, schema: Constructable<ModelSchema<T>>): (constructor: any) => void

  • A @Model is a class decorator and must be placed on top of a class representing a model.

    • A model must also extend a base model class.
    • For type safety, the type of model being decorated is passed to the decorator.
    @example
    @Model<MyModel>('@example', 'region', MyModelSchema)
    export class MyModel extends Region { ... }
    @group

    Decorators

    @see
    • Definition of Models.
    • App and Region are a few base models. More can be found in the same folder.

    Type parameters

    • T: UnknownModel

    Parameters

    • packageName: string

      The name of the package under which the model is registered. Selecting a unique package name helps avoid collisions between same model class names across different libraries. You will reuse the same package name throughout your library for different Octo components you create.

    • modelName: string

      a string that uniquely represents the base model you are extending. Octo provides names for each of the base models, and you must use the same name. E.g. for region base model, the model name is region.

    • schema: Constructable<ModelSchema<T>>

      The schema of the model.

    Returns (constructor: any) => void

    The decorated class.

      • (constructor: any): void
      • Parameters

        • constructor: any

        Returns void