Skip to main content

Model

Callable

  • Model<T>(packageName: string, modelName: keyof BaseModelSchemas, schema: Constructable<ModelSchema<T>>, options?: { createsNothing?: boolean }): (constructor: Constructable<T>) => 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

    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: keyof BaseModelSchemas

      The name of the base model you are extending, e.g. region for Region.

    • schema: Constructable<ModelSchema<T>>

      The schema of the model.

    • options: { createsNothing?: boolean } = {}

      Optional settings of the model.

      • options.createsNothing - The model creates no resources; other nodes only read from it. It declares no action, and each of its diffs is applied by one that does nothing.
      • optionalcreatesNothing: boolean = false

    Returns (constructor: Constructable<T>) => void

    The decorated class.