prorm API Reference
    Preparing search index...

    Class VIRTUALSTRING

    VIRTUALSTRING - virtual string field with getter/setter support Does not create a database column but provides computed string values

    // Virtual string with getter (computed from other fields)
    fullName: DataTypes.VIRTUALSTRING({
    get() {
    return `${this.firstName} ${this.lastName}`;
    },
    dependencies: ['firstName', 'lastName']
    })

    // Virtual string with getter and setter
    email: DataTypes.VIRTUALSTRING({
    get() {
    return this._email?.toLowerCase();
    },
    set(value: string) {
    this._email = value.trim().toLowerCase();
    },
    length: 255
    })

    Hierarchy (View Summary)

    Index
    key: "VIRTUALSTRING" = ...
    get?: () => string

    Getter function to compute the virtual string value

    set?: (value: string) => void

    Setter function to handle setting the virtual string

    length?: number

    Maximum length for validation (optional)

    dependencies?: string[]

    Array of field names that this virtual field depends on

    • Serialize a value for storage based on this DataType

      Parameters

      • value: unknown

        The value to serialize

      Returns unknown

      The serialized value

    • Get the dependencies for this virtual field

      Returns string[]

    • Get the maximum length for validation

      Returns number | undefined