@alpaca-software/40kdc-data
    Preparing search index...

    Interface CollectionConfig<T, V>

    How a Collection reads keys and builds views from raw records.

    interface CollectionConfig<T, V> {
        items: T[];
        idOf: (item: T) => string;
        dedupeKeyOf?: (item: T) => string;
        nameOf?: (item: T) => string | undefined;
        factionOf?: (item: T) => string | null | undefined;
        wrap: (item: T) => V;
    }

    Type Parameters

    • T
    • V
    Index

    Properties

    items: T[]
    idOf: (item: T) => string

    Primary id of a record (e.g. u => u.id, a => a.ability_id).

    dedupeKeyOf?: (item: T) => string

    Uniqueness key used for deduplication. Defaults to idOf. Set to a composite (e.g. (faction_id, id)) for records that share an id across factions, so distinct copies are preserved rather than collapsed.

    nameOf?: (item: T) => string | undefined

    Display name, if the record has one — drives Collection.find.

    factionOf?: (item: T) => string | null | undefined

    Owning faction id, if applicable — drives Collection.byFaction.

    wrap: (item: T) => V

    Wrap a raw record in its linked view.