@jiway/firestorm-core - v1.1.1
    Preparing search index...

    Class ToOneRelationship<T_target>

    Class holding a reference to an item that can be loaded or not

    Type Parameters

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    type: Type<T_target>

    Type of the model

    Accessors

    • get id(): string | null

      Gets the id of the document for this relationship.

      Returns string | null

    • set id(newId: string | null | undefined): void

      Sets the id for this relation.

      If there is a model already loaded and the newid makes the relationship invalid, it will remove the model aswell.

      Parameters

      • newId: string | null | undefined

        Id to assign.

      Returns void

    • get invalid(): boolean

      Whether or not the id and the model are mismatched.

      Returns boolean

      valid

    • get model(): T_target | undefined

      The loaded model

      Returns T_target | undefined

    • get modelIfValid(): T_target | undefined

      Gets the model if it is validated against the id, or undefined otherwise.

      Returns T_target | undefined

    • get valid(): boolean

      Whether or not the id and the model match.

      If the id is falsy, the value must be falsy too to be valid. If there is an id, then the model must be loaded and have the same id.

      Returns boolean

    Methods

    • Sets the model of the relationship. The model must have an id.

      It will update the id of the relationship.

      Parameters

      Returns void