functional-models
    Preparing search index...

    Interface OrmPropertyConfig<T>

    Additional configurations for ORM based properties.

    interface OrmPropertyConfig<T extends Arrayable<DataValue>> {
        autoNow?: boolean;
        choices?: readonly ChoiceTypes[];
        defaultValue?: T;
        fetcher?: ModelInstanceFetcher<object, object>;
        isArray?: boolean;
        isBoolean?: boolean;
        isDenormalized?: boolean;
        isInteger?: boolean;
        isNumber?: boolean;
        isString?: boolean;
        lazyLoadMethod?: <TData extends Readonly<{ [s: string]: any }>>(
            value: T,
            modelData: CreateParams<TData>,
        ) => T;
        lazyLoadMethodAtomic?: <TData extends Readonly<{ [s: string]: any }>>(
            value: T,
            modelData: CreateParams<TData>,
        ) => Promise<T>;
        maxLength?: number;
        maxValue?: number;
        minLength?: number;
        minValue?: number;
        required?: boolean;
        typeOverride?: string;
        unique?: string;
        validators?: readonly PropertyValidatorComponent<any, object, object>[];
        value?: T;
        valueSelector?: (instanceValue: MaybePromise<T>) => T;
    }

    Type Parameters

    Index

    Properties

    autoNow?: boolean

    If the value should be created automatically. Used in date creation.

    choices?: readonly ChoiceTypes[]

    Possible limiting choices of what the property can be.

    defaultValue?: T

    A default value if one is never given.

    fetcher?: ModelInstanceFetcher<object, object>

    If you are using ModelReferences, this is required. A fetcher used for getting model references. This configuration item is used within the AdvancedModelReferenceProperty and any other property that is lazy loading (atomically) models.

    isArray?: boolean

    Is the property an array of values?

    isBoolean?: boolean

    Is the property only true or false?

    isDenormalized?: boolean

    Determines if this value needs to go through denormalization.

    isInteger?: boolean

    Can the property only be an integer?

    isNumber?: boolean

    Can the property only be a number?

    isString?: boolean

    Can the property only be a string?

    lazyLoadMethod?: <TData extends Readonly<{ [s: string]: any }>>(
        value: T,
        modelData: CreateParams<TData>,
    ) => T

    A lazy loading method, which will only run when the value is actually retrieved. IMPORTANT: Do not include promises as part of this because they are not thread safe.

    Type declaration

      • <TData extends Readonly<{ [s: string]: any }>>(
            value: T,
            modelData: CreateParams<TData>,
        ): T
      • Type Parameters

        • TData extends Readonly<{ [s: string]: any }>

        Parameters

        • value: T

          The current value

        • modelData: CreateParams<TData>

          The models current data

        Returns T

    lazyLoadMethodAtomic?: <TData extends Readonly<{ [s: string]: any }>>(
        value: T,
        modelData: CreateParams<TData>,
    ) => Promise<T>

    A thread safe (Atomic) version of lazyLoadMethod. Use this for all lazy loadings that requires Promises.

    Type declaration

      • <TData extends Readonly<{ [s: string]: any }>>(
            value: T,
            modelData: CreateParams<TData>,
        ): Promise<T>
      • Type Parameters

        • TData extends Readonly<{ [s: string]: any }>

        Parameters

        • value: T

          The current value

        • modelData: CreateParams<TData>

          The models current data.

        Returns Promise<T>

    maxLength?: number

    The maximum length of the value. (Drives validation)

    maxValue?: number

    The maximum size of the value. (Drives validation)

    minLength?: number

    The minimum length of the value. (Drives validation)

    minValue?: number

    The minimum size of the value. (Drives validation)

    required?: boolean

    Is this property required?

    typeOverride?: string

    A type override to override the property type of a property.

    unique?: string

    Validator: Checks to make sure that there is only one instance in a datastore that has this property's value. NOTE: The value is a property KEY. Not true or false.

    validators?: readonly PropertyValidatorComponent<any, object, object>[]

    Additional validators for the property.

    value?: T

    The value of the property (if provided)

    valueSelector?: (instanceValue: MaybePromise<T>) => T

    An optional function that can select a "part" of the value to return.