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

    Class ToManyRelationship<T_target>

    Class holding references to multiple items of the same collection that can be loaded or not.

    The ids can be duplicated but the models are unique per id to avoid unecessary calls

    Type Parameters

    Index

    Constructors

    Properties

    type: Type<T_target>

    The type of models this relationship holds.

    Accessors

    • get ids(): string[]

      Gets the ids of the relationship.

      The ids are in order of insertion and is preserved in the document.

      Returns string[]

    • get models(): T_target[]

      Gets the models currently in the relationship.

      If

      Returns T_target[]

    • get uniqueIds(): string[]

      Gets the unique ids of the relationship

      The ids are in order of insertion but the duplicates are removed

      Returns string[]

    Methods

    • Adds multiple models to the relationship

      It adds the models' ids to the list of ids tracked by the relationship. If you want to assign the models without changing the list, use assignModels

      Parameters

      • models: Iterable<T_target>

        Models to add

      Returns ToManyRelationship<T_target>

      this

    • Assigns a model to the relationship if its id is tracked.

      It only assigns a model if this model's id is already in the list of tracked ids. If you want to add the model to the tracking, use addModel

      Parameters

      Returns ToManyRelationship<T_target>

      this

    • Assigns models to the relationship if their ids are tracked.

      It only assigns a model if this model's id is already in the list of tracked ids. If you want to add the model to the tracking, use addModels

      Parameters

      • models: Iterable<T_target>

        Models to assign

      Returns ToManyRelationship<T_target>

      this

    • Erase all the relationships stored

      Returns void

    • Gets a specific loaded item by its id

      Parameters

      • id: string

        Id of the item to retrieve

      Returns T_target | undefined

      The model if it exists or undefined if not loaded or not in the relationship at all.

    • Clears the current relationship and loaded models and add the ids provided in their place

      Parameters

      • ids: string | Iterable<string, any, any>

        The ids to add

      Returns ToManyRelationship<T_target>

      this

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

      It clears the relationship of any previous id tracking.

      Parameters

      • models: Iterable<T_target>

        Models to set

      Returns ToManyRelationship<T_target>