functional-models
    Preparing search index...

    Interface ModelType<TData, TModelExtensions, TModelInstanceExtensions>

    Represents a Model. A Model creates instances (ModelInstance) as well as describes generally about the data. (ModelDefinition).

    interface ModelType<
        TData extends DataDescription,
        TModelExtensions extends object = object,
        TModelInstanceExtensions extends object = object,
    > {
        create: <IgnoreProperties extends string = "">(
            data: CreateParams<TData, IgnoreProperties>,
        ) => ModelInstance<TData, TModelExtensions, TModelInstanceExtensions>;
        getApiInfo: () => Required<ApiInfo>;
        getModelDefinition: () => Readonly<
            {
                api?: Partial<ApiInfoPartialRest>;
                description: string;
                displayName: string;
                modelValidators: readonly ModelValidatorComponent<TData, object, object>[];
                namespace: string;
                pluralName: string;
                primaryKeyName: string;
                properties: PropertiesList<Required<TData>>;
                singularName: string;
            },
        >;
        getName: () => string;
        getPrimaryKey: (
            instanceData: TData | ToObjectResult<TData>,
        ) => PrimaryKeyType;
    }

    Type Parameters

    • TData extends DataDescription

      The type of data

    • TModelExtensions extends object = object

      Extensions on the model.

    • TModelInstanceExtensions extends object = object

      Extensions on the instances produced by this model.

    Index

    Properties

    create: <IgnoreProperties extends string = "">(
        data: CreateParams<TData, IgnoreProperties>,
    ) => ModelInstance<TData, TModelExtensions, TModelInstanceExtensions>

    Creates an instance of this model with the data that is provided.

    Type declaration

    getApiInfo: () => Required<ApiInfo>

    Gets the Api Information on the model.

    This will take what is manually provided via the ModelDefinition and autopopulate everything that is possible with default values, or values that make sense based on the ApiInformation provided.

    getModelDefinition: () => Readonly<
        {
            api?: Partial<ApiInfoPartialRest>;
            description: string;
            displayName: string;
            modelValidators: readonly ModelValidatorComponent<TData, object, object>[];
            namespace: string;
            pluralName: string;
            primaryKeyName: string;
            properties: PropertiesList<Required<TData>>;
            singularName: string;
        },
    >

    Gets the metadata that describes the model.

    getName: () => string

    This is a unique name combining namespace + pluralName. This can be used as a key to uniquely identify this model across an entire system. Example: pluralName=MyModels namespace=@my-package/namespace

    Return: '@my-package/namespace-my-models'

    getPrimaryKey: (instanceData: TData | ToObjectResult<TData>) => PrimaryKeyType

    Gets the primary key of instance data. This helpful method shortcuts having to figure out the primaryKey's name and then reaching inside the instance data to get the primary key.

    Type declaration