functional-models
    Preparing search index...

    Interface ModelInstance<TData, TModelExtensions, TModelInstanceExtensions>

    An instance of a Model. This "wrapper" fully embodies the power of the framework, and provides the most enrichment of a single piece of a data possible.

    interface ModelInstance<
        TData extends DataDescription,
        TModelExtensions extends object = object,
        TModelInstanceExtensions extends object = object,
    > {
        get: PropertyGetters<TData>;
        getModel: () => ModelType<
            TData,
            TModelExtensions,
            TModelInstanceExtensions,
        >;
        getPrimaryKey: () => PrimaryKeyType;
        getReferences: () => ModelReferenceFunctions;
        getValidators: () => Readonly<Record<string, PropertyValidator<TData>>>;
        toObj: ToObjectFunction<TData>;
        validate: (options?: object) => Promise<undefined | ModelErrors<TData>>;
    }

    Type Parameters

    • TData extends DataDescription

      The type of data

    • TModelExtensions extends object = object

      Extensions on the overall model.

    • TModelInstanceExtensions extends object = object

      Extensions on all instances of a model.

    Index

    Properties

    Gets the value of individual properties on the instance. These are memoized.

    Gets the model that backs this instance.

    getPrimaryKey: () => PrimaryKeyType

    Gets the primary key of the instance (without having to know the primary key name).

    getReferences: () => ModelReferenceFunctions

    Gets all model references that this instance may have as record of property name to function getter.

    getValidators: () => Readonly<Record<string, PropertyValidator<TData>>>

    Gets the validators for this model instance.

    Gets a basic representation of the data. This function is memoized.

    validate: (options?: object) => Promise<undefined | ModelErrors<TData>>

    Runs validation against this instance. This function is memoized.